/* HomeAgentHub — app.css
 * Tailwind (CDN) supplies utilities; this file holds brand tokens, the mobile app shell,
 * cards, badges, the single orchestrated hero load animation and reduced-motion handling.
 */

:root {
  --color-primary: #1B4FCC;
  --color-primary-dark: #163FA3;
  --color-accent: #F5A623;
  --color-dark: #0D1B2A;
  --color-surface: #F7F9FC;
  --color-text: #1A1A2E;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--color-surface);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1,h2,h3,h4,h5,h6 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  letter-spacing: -0.01em;
}
.font-display { font-family: 'Plus Jakarta Sans', sans-serif; }

[x-cloak] { display: none !important; }

:focus-visible { outline: 3px solid rgba(27,79,204,.45); outline-offset: 2px; border-radius: 6px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  padding-top: var(--safe-top);
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(13,27,42,.06);
}
.site-header.on-dark { background: rgba(13,27,42,.85); border-bottom-color: rgba(255,255,255,.06); }

/* ---------- Mobile bottom nav ---------- */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: white;
  border-top: 1px solid #e5e7eb;
  z-index: 1000;
  align-items: center;
  justify-content: space-around;
}

@media (max-width: 767px) {
  .mobile-bottom-nav { display: flex; }
  body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
}

.mobile-bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  color: #6b7280;
  text-decoration: none;
  min-height: 44px;
  min-width: 56px;
  justify-content: center;
  gap: 3px;
  font-weight: 600;
}

.mobile-bottom-nav .nav-item.active { color: var(--color-accent); }
.mobile-bottom-nav .nav-item svg { width: 22px; height: 22px; }
.mobile-bottom-nav .nav-item:active { transform: scale(.94); }

/* ---------- Page load fade ---------- */
body { opacity: 0; transition: opacity 0.3s ease; }
body.loaded { opacity: 1; }

/* The one orchestrated page-load animation: hero content enters in sequence. */
.hero-seq > * { opacity: 0; transform: translateY(14px); }
body.loaded .hero-seq > * {
  animation: heroIn .7s cubic-bezier(.2,.7,.2,1) forwards;
}
body.loaded .hero-seq > *:nth-child(1) { animation-delay: .05s; }
body.loaded .hero-seq > *:nth-child(2) { animation-delay: .17s; }
body.loaded .hero-seq > *:nth-child(3) { animation-delay: .29s; }
body.loaded .hero-seq > *:nth-child(4) { animation-delay: .41s; }
body.loaded .hero-seq > *:nth-child(5) { animation-delay: .53s; }
@keyframes heroIn { to { opacity: 1; transform: none; } }

/* Smooth same-origin page transitions where supported */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }

/* ---------- Star rating ---------- */
.stars-filled { color: var(--color-accent); }
.stars-empty { color: #d1d5db; }

/* ---------- Listing cards ---------- */
.listing-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.listing-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }

.listing-card-featured {
  border-top: 3px solid var(--color-accent);
  box-shadow: 0 4px 20px rgba(27,79,204,0.12);
}

/* ---------- Badges ---------- */
.badge-featured {
  background: var(--color-accent);
  color: #0D1B2A;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
}
.badge-agent { background: #EFF6FF; color: #1B4FCC; }
.badge-agency { background: #F3F4F6; color: #374151; }

.featured-ribbon {
  position: absolute;
  top: 18px;
  right: -42px;
  transform: rotate(45deg);
  background: var(--color-accent);
  color: #0D1B2A;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 6px 48px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* ---------- Touch targets ---------- */
button, a.btn, .nav-item { min-height: 44px; }
input, select, textarea { font-size: 16px; } /* prevents iOS zoom on focus */

/* ---------- Hero ---------- */
.hero {
  position: relative;
  background: var(--color-dark);
  color: #fff;
  overflow: hidden;
  isolation: isolate;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 50% at 85% 10%, rgba(27,79,204,.45), transparent 70%),
    radial-gradient(40% 40% at 10% 90%, rgba(245,166,35,.16), transparent 70%);
}
.hero-grid {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .08;
  background-image: linear-gradient(rgba(255,255,255,.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.6) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.hero-home { min-height: 70vh; }
@media (min-width: 768px) { .hero-home { min-height: 100vh; min-height: 100svh; } }

.search-shell {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}

.city-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.9);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s ease, border-color .15s ease;
}
.city-pill:hover { background: rgba(255,255,255,.08); border-color: rgba(245,166,35,.7); }

/* ---------- City cards ---------- */
.city-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 14px 18px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  transition: border-color .15s ease, transform .15s ease;
}
.city-card:hover { border-color: var(--color-primary); }
.city-card:hover .city-arrow { transform: translateX(3px); color: var(--color-primary); }
.city-arrow { transition: transform .15s ease; color: #9ca3af; }

/* ---------- Horizontal swipe rail (mobile) ---------- */
.swipe-rail {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 6px;
}
.swipe-rail::-webkit-scrollbar { display: none; }
.swipe-rail > * { scroll-snap-align: start; flex: 0 0 82%; }

/* Swiper overrides */
.swiper-featured { padding-bottom: 36px !important; }
.swiper-featured .swiper-slide { height: auto; }
.swiper-featured .swiper-pagination-bullet-active { background: var(--color-accent); }

/* ---------- Forms ---------- */
.form-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: var(--color-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(27,79,204,.15); }
.form-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: #374151; }

.btn-primary, .btn-gold, .btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 10px;
  font-weight: 700;
  transition: background .15s ease, filter .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-gold { background: var(--color-accent); color: var(--color-dark); }
.btn-gold:hover { filter: brightness(.95); }
.btn-outline { border: 1.5px solid currentColor; }

/* ---------- Prose (legal/about pages) ---------- */
.prose-hah { line-height: 1.75; color: #374151; }
.prose-hah h2 { font-size: 1.35rem; font-weight: 800; color: var(--color-text); margin: 2rem 0 .75rem; }
.prose-hah h3 { font-size: 1.1rem; font-weight: 700; color: var(--color-text); margin: 1.5rem 0 .5rem; }
.prose-hah p { margin: 0 0 1rem; }
.prose-hah ul { list-style: disc; padding-left: 1.25rem; margin: 0 0 1rem; }
.prose-hah li { margin: .35rem 0; }
.prose-hah a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(13,27,42,.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, var(--safe-top)) 16px max(16px, var(--safe-bottom));
}
.lightbox img { max-width: 100%; max-height: 85vh; border-radius: 10px; object-fit: contain; }

/* ---------- Loading skeleton for AJAX search ---------- */
.results-loading { opacity: .45; pointer-events: none; transition: opacity .15s ease; }

/* ---------- Misc ---------- */
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pb-safe { padding-bottom: max(16px, var(--safe-bottom)); }

/* Tom Select tweaks */
.ts-wrapper.single .ts-control { min-height: 48px; border-radius: 10px; border-color: #d1d5db; padding: 12px 14px; font-size: 16px; box-shadow: none; }
.ts-wrapper.focus .ts-control { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(27,79,204,.15); }
.ts-dropdown { border-radius: 10px; font-size: 15px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
  body, body.loaded { opacity: 1; }
  .hero-seq > * { opacity: 1; transform: none; }
}
