/* =============================================================================
   realestatehunt.ca — Design System (Direction A · Dark)
   Compass × Linear × Vercel hybrid. Deep ink canvas, warm cream text, glow accent.

   Every other stylesheet references these tokens. Change here, propagates
   everywhere. Don't hardcode colors / fonts / spacing anywhere else.
   ============================================================================= */

/* ------- Google Fonts: Inter + Inter Tight + JetBrains Mono ------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ===== Color tokens — DARK CANVAS ===== */
  --brand:          #ff6b3d;          /* warmer, glows on dark */
  --brand-dark:     #e0552a;          /* hover / pressed */
  --brand-light:    rgba(255, 107, 61, 0.12);
  --brand-glow:     rgba(255, 107, 61, 0.35);

  /* "Ink" = the foreground (text). Cream-white scale. */
  --ink:            #fafaf7;          /* near-cream for headlines */
  --ink-2:          #e5e5e3;          /* body text */
  --ink-3:          #9a9a96;          /* secondary text */
  --ink-4:          #656562;          /* tertiary, captions */
  --ink-5:          #2a2a28;          /* dividers (legacy alias) */

  /* "Paper" = the background. Deep ink scale. */
  --paper:          #0a0a0a;          /* primary background */
  --paper-2:        #131313;          /* subtle elevation */
  --paper-3:        #1c1c1c;          /* card surface */
  --paper-4:        #242422;          /* hovered surface */

  --line:           rgba(255, 255, 255, 0.07);     /* default border */
  --line-strong:    rgba(255, 255, 255, 0.14);
  --line-brand:     rgba(255, 107, 61, 0.4);

  --success:        #22c55e;
  --danger:         #ef4444;
  --warning:        #f97316;

  /* Glass surface — used on hero overlays */
  --glass:          rgba(20, 20, 20, 0.55);
  --glass-strong:   rgba(28, 28, 28, 0.75);

  /* ===== Type scale ===== */
  --font-display:   'Inter Tight', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:      'JetBrains Mono', ui-monospace, monospace;

  --size-hero:      clamp(2.75rem, 5.5vw + 1rem, 5.5rem);   /* 44 → 88px */
  --size-h1:        clamp(2rem, 3vw + 1rem, 3rem);
  --size-h2:        clamp(1.5rem, 2vw + 0.8rem, 2.25rem);
  --size-h3:        1.25rem;
  --size-body:      1rem;
  --size-small:     0.875rem;
  --size-tiny:      0.75rem;

  --weight-regular: 400;
  --weight-medium:  500;
  --weight-semi:    600;
  --weight-bold:    700;

  /* ===== Spacing scale (8px base) ===== */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;
  --s-9: 6rem;
  --s-10: 8rem;

  /* ===== Radius ===== */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-2xl: 28px;
  --r-pill: 999px;

  /* ===== Shadows — restrained, glow-led on dark ===== */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.55), 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 0 4px var(--brand-glow);
  --shadow-brand: 0 8px 32px rgba(255, 107, 61, 0.25);

  /* ===== Motion ===== */
  --ease:        cubic-bezier(0.16, 1, 0.3, 1);    /* "expo out" — Linear's curve */
  --ease-snap:   cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast:      150ms;
  --t-base:      250ms;
  --t-slow:      400ms;

  /* ===== Layout ===== */
  --width-narrow:    640px;
  --width-content:   1100px;
  --width-wide:      1320px;
  --nav-h:           64px;
}

/* ============================================================================
   RESET — minimal, opinionated
   ============================================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--paper); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: var(--weight-semi);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
}
h1 { font-size: var(--size-h1); letter-spacing: -0.035em; }
h2 { font-size: var(--size-h2); }
h3 { font-size: var(--size-h3); }
p  { margin: 0; }
a  { color: inherit; text-decoration: none; }
img, video { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
.mono { font-family: var(--font-mono); }
::selection { background: var(--brand); color: var(--paper); }

/* ============================================================================
   LAYOUT primitives
   ============================================================================ */
.container       { width: 100%; max-width: var(--width-wide);    margin: 0 auto; padding: 0 var(--s-5); }
.container-narrow{ width: 100%; max-width: var(--width-narrow);  margin: 0 auto; padding: 0 var(--s-5); }
.container-content { width: 100%; max-width: var(--width-content); margin: 0 auto; padding: 0 var(--s-5); }

/* ============================================================================
   TOP NAV — frosted dark
   ============================================================================ */
.nav {
  position: sticky; top: 0; z-index: 50;
  min-height: var(--nav-h);
  padding-top: env(safe-area-inset-top, 0px);   /* clears the notch in standalone PWA */
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  height: var(--nav-h); max-width: var(--width-wide); margin: 0 auto;
  padding: 0 max(var(--s-5), env(safe-area-inset-right)) 0 max(var(--s-5), env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-5);
}
.nav-brand {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--ink);
}
.nav-brand .accent { color: var(--brand); }
.nav-links { display: flex; align-items: center; gap: 18px; flex-wrap: nowrap; }
.nav-links a {
  font-size: var(--size-small);
  font-weight: var(--weight-medium);
  color: var(--ink-3);
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--brand); }
/* Below 1100px, suppress the secondary auth links to keep the nav single-line.
   Sign in / Sign out / My Hub remain reachable via /account in the footer
   and via the CTA button. Tools and Commercial are the first to fold. */
@media (max-width: 1180px) {
  .nav-links { gap: 14px; }
  .nav-links a { font-size: 13px; }
}
@media (max-width: 900px) {
  .nav-links { gap: 12px; }
  .nav-links a { font-size: 12.5px; }
}
@media (max-width: 720px) {
  /* Hamburger toggle replaces hidden links. Activated by JS at bottom of file. */
  .nav-links a:not(.cta):not(.nav-keep):not(.nav-brand) { display: none; }
  .nav-inner::after {
    content: "☰";
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 38px; height: 38px;
    margin-left: 8px;
    font-size: 22px; line-height: 1;
    color: var(--ink);
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
}

/* ============================================================
   MOBILE NAV DRAWER — full-screen menu when hamburger tapped.
   JS in design.css.js below attaches click handler to ::after
   pseudo-element via a transparent overlay button.
   ============================================================ */
.mobile-nav-btn {
  display: none;
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
  z-index: 1000;
  align-items: center; justify-content: center;
}
@media (max-width: 720px) {
  /* Reserve room on the right so the hamburger never sits on top of the
     "Sign up free" CTA that stays visible in the collapsed nav. */
  .nav-inner { position: relative; padding-right: 62px; }
  .mobile-nav-btn { display: inline-flex; right: 14px; }
  /* Hide CSS-only hamburger glyph since real button takes over */
  .nav-inner::after { display: none; }
}

/* Wide tables (deal feed, comps) scroll inside their own box on phones
   instead of pushing the whole page sideways. JS wraps each <table> in
   .table-scroll (see mobile-nav.js); this styles that wrapper. */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.mobile-nav-drawer {
  position: fixed; inset: 0;
  background: rgba(10,10,11,0.98);
  z-index: 9999;
  display: none;
  flex-direction: column;
  padding: max(80px, calc(env(safe-area-inset-top) + 56px)) 24px max(32px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mobile-nav-drawer.open { display: flex; }
.mobile-nav-drawer a {
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  text-decoration: none;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  display: block;
}
.mobile-nav-drawer a.active { color: var(--brand); }
.mobile-nav-drawer-close {
  position: absolute; top: 20px; right: 16px;
  width: 42px; height: 42px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 24px;
  cursor: pointer;
}

/* ============================================================
   GLOBAL RESPONSIVE FIXES — apply across every template
   ============================================================ */
@media (max-width: 720px) {
  /* Body padding shrinks */
  body { font-size: 15px; }

  /* All grids that use minmax stack to 1 column on phones */
  [style*="grid-template-columns:repeat(auto-fit,minmax"],
  [style*="grid-template-columns: repeat(auto-fit, minmax"] {
    grid-template-columns: 1fr !important;
  }

  /* Inline-style fixed widths above 480px clamp to viewport */
  [style*="max-width:1180px"], [style*="max-width: 1180px"],
  [style*="max-width:1100px"], [style*="max-width: 1100px"],
  [style*="max-width:980px"],  [style*="max-width: 980px"],
  [style*="max-width:920px"],  [style*="max-width: 920px"],
  [style*="max-width:800px"],  [style*="max-width: 800px"],
  [style*="max-width:760px"],  [style*="max-width: 760px"],
  [style*="max-width:720px"],  [style*="max-width: 720px"],
  [style*="max-width:700px"],  [style*="max-width: 700px"] {
    max-width: 100% !important;
  }

  /* Modal-bg / .modal — full width with safe padding */
  .modal-bg .modal,
  .modal { max-width: 92vw !important; padding: 20px !important; }

  /* Buttons full-width inside cards/modals on mobile */
  .modal .row button { flex: 1; min-width: 0; }

  /* Generic .row flex containers gracefully wrap */
  .row, [style*="display:flex"][style*="gap"]:not(.lens-tabs) { flex-wrap: wrap; }

  /* Tighter section padding */
  section { padding-left: 16px !important; padding-right: 16px !important; }

  /* Headlines shrink */
  h1 { font-size: clamp(26px, 7vw, 36px) !important; line-height: 1.15 !important; }
  h2 { font-size: clamp(22px, 5.5vw, 28px) !important; }

  /* Hero stat chips smaller */
  .nav-brand { font-size: 17px !important; }
}

/* Tap targets — Apple HIG 44pt min */
@media (max-width: 720px) {
  button, .btn, a.btn, .lens-tabs button, .fsel, select, input[type="text"], input[type="number"], input[type="email"], input[type="tel"] {
    min-height: 44px;
  }
  /* iOS Safari zooms the whole page when a focused field is under 16px.
     Pin form controls to 16px on phones to stop the jarring zoom. */
  input, select, textarea { font-size: 16px; }
}

/* Mobile-friendly deal feed: cards single-column, lens tabs scroll horizontally */
@media (max-width: 720px) {
  .grid#grid {
    grid-template-columns: 1fr !important;
  }
  .filters { flex-direction: column; align-items: stretch !important; }
  .lens-tabs { overflow-x: auto; white-space: nowrap; flex-wrap: nowrap !important; }
  .lens-tabs::-webkit-scrollbar { display: none; }
  .fsel { width: 100% !important; }
}

/* Property page photo grid: 1 hero + scroll thumbs on mobile */
@media (max-width: 720px) {
  .photo-header { grid-template-columns: 1fr !important; grid-template-rows: auto !important; }
  .photo-header > * { aspect-ratio: 4/3; }
  .pp-price { font-size: 32px !important; }
  .pp-price-row { flex-direction: column !important; align-items: flex-start !important; gap: 4px !important; }
  .pp-address { font-size: 20px !important; }
}
.nav-links a.cta {
  background: var(--brand); color: var(--paper) !important;
  padding: 8px 14px; border-radius: var(--r-md);
  font-weight: var(--weight-semi);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.nav-links a.cta:hover {
  background: var(--brand-dark); transform: translateY(-1px);
  box-shadow: var(--shadow-brand);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 12px 20px;
  font-size: var(--size-small);
  font-weight: var(--weight-semi);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn-primary {
  background: var(--brand); color: var(--paper);
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, var(--shadow-brand);
}
.btn-primary:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 12px 36px rgba(255, 107, 61, 0.35);
}
.btn-secondary {
  background: rgba(255,255,255,0.04); color: var(--ink);
  border-color: var(--line-strong);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover {
  border-color: var(--ink);
  background: rgba(255,255,255,0.08);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent; color: var(--ink-2);
}
.btn-ghost:hover { background: var(--paper-3); color: var(--ink); }
.btn-lg { padding: 16px 28px; font-size: 1rem; }

/* ============================================================================
   NATIVE-FEEL TOUCH INTERACTIONS
   Tactile press feedback, no accidental text-selection on controls, and
   momentum scrolling on horizontal strips. Press scaling is scoped to touch
   devices so desktop hover behaviour is untouched.
   ============================================================================ */
.btn, button, a.btn, .nav-links a.cta, .csc-ask, .csc-browse,
.chat-option-btn, .chat-chip, .photo-action-btn, .fsa-pill, .lens-tabs button {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
@media (hover: none) {
  .btn:active, button:active, a.btn:active, .nav-links a.cta:active,
  .csc-ask:active, .csc-browse:active, .chat-option-btn:active,
  .chat-chip:active, .card-hover:active, .fsa-pill:active {
    transform: scale(0.97);
    transition: transform 60ms ease;
  }
}
/* Smooth momentum scrolling on horizontal strips */
.lens-tabs, .table-scroll, .photo-thumbs, [class*="-scroll"] {
  -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: transform var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease),
              background var(--t-base) var(--ease);
}
.card-hover:hover {
  transform: translateY(-2px);
  background: var(--paper-4);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-3);
}

/* ============================================================================
   AURORA BACKGROUND — used behind the hero
   Glowing radial gradients in brand color, soft on a dark canvas.
   ============================================================================ */
.aurora {
  position: relative;
  overflow: hidden;
  background: var(--paper);
}
.aurora::before {
  content: '';
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(at 18% 24%, rgba(255, 107, 61, 0.22) 0%, transparent 38%),
    radial-gradient(at 82% 18%, rgba(255, 154, 70, 0.14) 0%, transparent 35%),
    radial-gradient(at 60% 88%, rgba(255, 107, 61, 0.12) 0%, transparent 45%),
    radial-gradient(at 30% 78%, rgba(120, 80, 200, 0.06) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
  filter: blur(8px);
}
.aurora > * { position: relative; z-index: 1; }

/* Subtle dotted grid texture, used on dark hero backgrounds */
.grid-bg {
  background-image:
    radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ============================================================================
   SCROLL-TRIGGERED FADE-IN
   ============================================================================ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
}
.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================================
   UTILITIES
   ============================================================================ */
.muted    { color: var(--ink-3); }
.tiny     { font-size: var(--size-tiny); color: var(--ink-4); letter-spacing: 0.02em; }
.eyebrow  {
  font-family: var(--font-mono); font-size: var(--size-tiny);
  font-weight: var(--weight-medium); text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--brand);
}
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 2.2s var(--ease) infinite;
  display: inline-block;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* gradient text utility */
.gradient-text {
  background: linear-gradient(180deg, #fafaf7 0%, #a3a3a0 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* =============================================================================
   Themed scrollbars — match the dark canvas. Without this, the OS gives us a
   bright-white track that breaks the Direction A look anywhere content
   overflows (listings columns, drawers, chat bodies).
   ============================================================================= */

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--paper-4) transparent;
}

/* WebKit / Blink (Chrome, Edge, Safari) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--paper-4);
  border-radius: 5px;
  border: 2px solid var(--paper);  /* "padding" effect, keeps thumb slim */
}
::-webkit-scrollbar-thumb:hover {
  background: var(--brand);
}
::-webkit-scrollbar-corner {
  background: transparent;
}
