/* ===========================================================================
   HOME HARVEST — Apple-inspired design system (v2)
   No corner logos · site-wide aurora gradient · refined brief · route view
   =========================================================================== */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #86868b;
  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.05);
  --blue: #0071e3;
  --blue-press: #0077ed;
  --violet: #5e5ce6;
  --green: #34c759;
  --amber: #ff9f0a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 6px 16px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 30px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05);
  --radius: 22px;
  --radius-sm: 16px;
  --maxw: 1160px;
  --gap: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* [hidden] must win over flex/grid display rules below (fixes tab switcher) */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.47;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex; flex-direction: column;
  overflow-x: hidden;
}

/* ---- Site-wide aurora gradient wash -------------------------------------- */
.aurora {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 82% -8%, rgba(0,113,227,0.14), transparent 62%),
    radial-gradient(55% 45% at -8% 6%, rgba(94,92,230,0.12), transparent 60%),
    radial-gradient(50% 40% at 50% 108%, rgba(52,199,89,0.10), transparent 60%),
    linear-gradient(180deg, #f7f8fb 0%, #f5f5f7 40%, #f3f4f7 100%);
}

/* ---- Main ---------------------------------------------------------------- */
main { flex: 1; position: relative; z-index: 1; width: 100%;
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.hero { text-align: center; padding: 76px 0 34px; }
.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: 0.16em;
  color: var(--blue); margin-bottom: 18px;
}
.headline {
  font-size: clamp(38px, 6vw, 68px);
  font-weight: 700; letter-spacing: -0.035em; line-height: 1.03;
  background: linear-gradient(175deg, #1d1d1f 8%, #3f4c68 96%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub {
  margin: 20px auto 0; max-width: 560px;
  font-size: clamp(16px, 2.1vw, 21px); color: var(--ink-2);
  font-weight: 400; letter-spacing: -0.012em;
}

/* ---- Search bar ---------------------------------------------------------- */
.searchbar {
  margin: 38px auto 0; max-width: 660px;
  display: flex; gap: 12px; align-items: stretch;
  flex-wrap: wrap; justify-content: center;
}
.field {
  position: relative; flex: 1 1 260px; min-width: 210px;
  display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 980px; box-shadow: var(--shadow-sm);
  transition: box-shadow .22s ease, border-color .22s ease;
}
.field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,0.15), var(--shadow-sm); }
.field-icon { margin-left: 20px; color: var(--ink-3); flex: none; }
.field input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-family: var(--font); font-size: 17px; color: var(--ink);
  padding: 16px 20px 16px 12px; letter-spacing: 0.01em;
}
.field input::placeholder { color: var(--ink-3); letter-spacing: -0.011em; }
.field.range { flex: 0 0 auto; min-width: 0; }
.field.range select {
  appearance: none; -webkit-appearance: none; border: 0; outline: 0; background: transparent;
  font-family: var(--font); font-size: 16px; color: var(--ink);
  padding: 16px 44px 16px 24px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2386868b' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 20px center;
}
.go {
  flex: 0 0 auto; position: relative;
  border: 0; cursor: pointer; border-radius: 980px;
  background: linear-gradient(180deg, #0a84ff, #0071e3);
  color: #fff; font-family: var(--font); font-size: 17px; font-weight: 500;
  padding: 0 30px; min-height: 54px; min-width: 122px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 12px rgba(0,113,227,0.38);
  transition: filter .2s ease, transform .08s ease, box-shadow .2s ease;
}
.go:hover { filter: brightness(1.05); }
.go:active { transform: scale(0.97); }
.go[disabled] { opacity: 0.72; cursor: default; }
.spinner {
  display: none; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.go.loading .go-label { display: none; }
.go.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.hint { margin-top: 18px; font-size: 13px; color: var(--ink-3); }

/* ---- Results ------------------------------------------------------------- */
.results { padding: 8px 0 48px; animation: rise .55s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---- Brief (refined) ----------------------------------------------------- */
.brief {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #ffffff 0%, #fbfcff 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 26px 22px 30px; margin-bottom: 22px;
  box-shadow: var(--shadow-md);
}
.brief::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: linear-gradient(180deg, var(--blue), var(--violet));
}
.brief-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.15em;
  color: var(--violet); margin-bottom: 12px; text-transform: uppercase;
}
.brief-body { font-size: 16px; color: #2c2c33; line-height: 1.55; }
.brief-line { display: flex; gap: 12px; padding: 5px 0; align-items: baseline; }
.brief-line + .brief-line { border-top: 1px solid var(--line-2); }
.brief-tag {
  flex: none; font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  color: #fff; border-radius: 7px; padding: 3px 9px; margin-top: 1px; min-width: 60px; text-align: center;
}
.bt-where { background: var(--blue); }
.bt-who { background: var(--violet); }
.bt-pitch { background: var(--green); }
.brief-text { flex: 1; }

/* ---- Head: stats + tabs -------------------------------------------------- */
.results-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 18px;
}
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 18px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; min-width: 98px;
}
.stat b { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--ink-3); margin-top: 3px; }

.tabs {
  display: inline-flex; background: rgba(120,120,128,0.12);
  border-radius: 980px; padding: 4px; gap: 2px;
}
.tab {
  border: 0; cursor: pointer; font-family: var(--font);
  font-size: 15px; font-weight: 500; color: var(--ink-2);
  padding: 8px 20px; border-radius: 980px; background: transparent;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---- Split layout -------------------------------------------------------- */
.split { display: grid; grid-template-columns: 1.12fr 1fr; gap: var(--gap); align-items: start; }
.map-wrap { position: sticky; top: 20px; }
.map {
  height: 640px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow-md);
}
.leaflet-container { font-family: var(--font); background: #eef0f3; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  overflow: hidden; display: flex; flex-direction: column; max-height: 640px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line-2);
  font-size: 15px; font-weight: 600; background: var(--surface-2);
}
.list, .route-list {
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto; padding: 14px; flex: 1;
}
.list::-webkit-scrollbar, .route-list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb, .route-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.14); border-radius: 8px; }

.ghost-btn {
  text-decoration: none; font-size: 14px; font-weight: 500; color: var(--blue);
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 16px; border-radius: 980px;
  transition: background .15s ease, transform .08s ease;
}
.ghost-btn:hover { background: #f5f7fb; }
.ghost-btn:active { transform: scale(0.97); }

/* ---- Lead cards ---------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px;
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
  display: flex; gap: 14px; align-items: flex-start;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: rgba(0,113,227,0.3); }
.card.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,113,227,0.15), var(--shadow-md); }
.thumb {
  flex: none; width: 66px; height: 66px; border-radius: 12px; object-fit: cover;
  background: #eef0f3; border: 1px solid var(--line-2);
}
.card-body { flex: 1; min-width: 0; }
.addr { font-size: 15px; font-weight: 600; letter-spacing: -0.012em; }
.meta { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.tag { font-size: 11px; color: var(--ink-2); background: #f2f2f4; border-radius: 7px; padding: 3px 9px; }
.price { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.scorepill {
  flex: none; display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700; color: #fff; border-radius: 980px;
  padding: 5px 11px; margin-top: 2px;
}
.s-hot { background: var(--green); }
.s-warm { background: var(--amber); }
.s-cool { background: #8e8e93; }

/* ---- Route cards --------------------------------------------------------- */
.rcard {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-sm);
  overflow: hidden; transition: box-shadow .2s ease, border-color .2s ease;
}
.rcard.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,113,227,0.15), var(--shadow-md); }
.rcard-head {
  display: flex; align-items: center; gap: 12px; padding: 13px 15px; cursor: pointer;
}
.rbadge {
  flex: none; width: 34px; height: 34px; border-radius: 11px; color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, var(--blue), var(--violet));
}
.rmeta { flex: 1; min-width: 0; }
.rtitle { font-size: 15px; font-weight: 600; }
.rsub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.rscore { flex: none; font-size: 12px; font-weight: 700; color: #fff; background: var(--green); border-radius: 980px; padding: 4px 10px; }
.rstops { border-top: 1px solid var(--line-2); padding: 4px 0; display: none; }
.rcard.open .rstops { display: block; }
.rstop {
  display: flex; align-items: center; gap: 10px; padding: 7px 15px; font-size: 13px; cursor: pointer;
}
.rstop:hover { background: var(--surface-2); }
.rstop .n {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: #eef0f3;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink-2);
}
.rstop .sa { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Empty --------------------------------------------------------------- */
.empty { padding: 48px 0 64px; display: grid; place-items: center; animation: rise .4s ease both; }
.empty-card {
  text-align: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 44px 38px; box-shadow: var(--shadow-md); max-width: 440px;
}
.empty-emoji { font-size: 42px; margin-bottom: 12px; }
.empty-card p { color: var(--ink-2); font-size: 16px; }

/* ---- Footer -------------------------------------------------------------- */
.foot {
  position: relative; z-index: 1; text-align: center;
  padding: 30px 24px 40px; color: var(--ink-3); font-size: 12px;
  display: flex; gap: 9px; justify-content: center; flex-wrap: wrap;
}
.foot .dot { opacity: 0.5; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .map-wrap { position: relative; top: 0; }
  .map { height: 400px; }
  .panel { max-height: none; }
  .list, .route-list { max-height: 560px; }
  .hero { padding: 52px 0 26px; }
  .searchbar { flex-direction: column; }
  .field, .go { width: 100%; }
  .field.range select { width: 100%; }
  .results-head { flex-direction: column; align-items: stretch; }
  .tabs { align-self: center; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --surface: #1c1c1e; --surface-2: #242426; --ink: #f5f5f7; --ink-2: #aeaeb2;
    --ink-3: #8e8e93; --line: rgba(255,255,255,0.12); --line-2: rgba(255,255,255,0.07);
  }
  .aurora {
    background:
      radial-gradient(60% 50% at 82% -8%, rgba(10,132,255,0.20), transparent 62%),
      radial-gradient(55% 45% at -8% 6%, rgba(94,92,230,0.18), transparent 60%),
      radial-gradient(50% 40% at 50% 108%, rgba(52,199,89,0.12), transparent 60%),
      linear-gradient(180deg, #0a0a0c 0%, #000 100%);
  }
  .headline { background: linear-gradient(175deg, #f5f5f7, #b9c2d6); -webkit-background-clip: text; background-clip: text; }
  .brief { background: linear-gradient(135deg, #1c1c1e, #202028); }
  .brief-body { color: #e6e6ea; }
  .tag { background: rgba(255,255,255,0.08); }
  .rstop .n, .thumb, .leaflet-container { background: #2a2a2c; }
  .tabs { background: rgba(255,255,255,0.10); }
  .ghost-btn:hover { background: #2a2a2c; }
}
