/* Realty of India — design tokens
 *
 * Palette + fonts restored to the original Claude Design spec
 * (project/Realty of India.html): warm ivory/ink/saffron neutrals,
 * Instrument Serif for display, Geist for body, Noto Sans Devanagari
 * for Hindi.
 *
 * Infrastructure improvements retained from later passes:
 *  - 17px root font-size + explicit body line-height for 40–60 y/o eyes
 *  - contrast-tightened ink tiers that pass WCAG AA on ivory
 *  - [data-theme="dark"] + prefers-color-scheme fallback
 *  - `--fs-*` scale, `--lh-*` tokens, `--tap` touch-target baseline
 *
 * Do NOT introduce cream/maroon/marigold/Playfair/Mukta here — those
 * were a festive experiment; the winning direction is the original
 * warm-editorial palette. Festive lives only as a seasonal override
 * (future `[data-season="diwali"]` block).
 */

:root {
  /* ── Colors (oklch) ─────────────────────────────────────────── */
  --ivory:        oklch(0.985 0.008 85);
  --ivory-2:      oklch(0.965 0.012 85);
  --paper:        oklch(0.995 0.004 85);
  --paper-2:      oklch(0.975 0.010 85);
  --line:         oklch(0.90 0.012 80);
  --line-2:       oklch(0.84 0.015 80);

  /* Ink tiers — AA-tightened from the original for better readability
   * on ivory without changing the warm-neutral feel.
   *   ink   → body text (≥ 7:1 AAA)
   *   ink-2 → secondary (≥ 7:1)
   *   ink-3 → tertiary / meta (≥ 4.5:1)
   *   ink-4 → decorative only (≥ 3:1) — never for content. */
  --ink:          oklch(0.22 0.015 60);
  --ink-2:        oklch(0.32 0.012 60);
  --ink-3:        oklch(0.44 0.010 60);
  --ink-4:        oklch(0.56 0.008 60);

  --saffron:      oklch(0.68 0.16 55);
  --saffron-deep: oklch(0.48 0.17 48);      /* AA-passing text variant on ivory */
  --saffron-soft: oklch(0.95 0.035 75);
  --green:        oklch(0.50 0.12 155);
  --green-soft:   oklch(0.94 0.03 155);
  --red:          oklch(0.52 0.17 25);
  --red-soft:     oklch(0.95 0.03 25);

  /* Semantic aliases — promoted from `var(--name, #hex)` fallbacks that
   * accumulated in app.css without ever being defined here. Values match
   * the fallback hexes verbatim so zero visual change; the call sites
   * now resolve through tokens.css instead of silently using the hex
   * fallback. Tighten / replace with oklch later as the design matures. */
  --surface:      #fff;
  --surface-2:    #fafafa;
  --border:       #e8e8e8;
  --accent:       #c62b3f;
  --accent-soft:  #fff1f3;   /* matches the inline fallback at .dash-action chips */

  /* ── Discovery card tones (homepage metro / locality grids) ─────
   * 6 tone pairs used by .ph-card--{tone} modifier classes. Each
   * pair renders as a 135° linear-gradient in the card body. Hues
   * are clustered around the existing warm-neutral palette (saffron,
   * sand, ivory, charcoal, rose, sage) so cards feel coherent
   * regardless of which tone a city/locality is hashed to.
   * Lightness held high (0.84–0.97) so dark ink text stays AA. */
  --card-tone-saffron-a:  oklch(0.93 0.06 75);
  --card-tone-saffron-b:  oklch(0.86 0.10 60);
  --card-tone-ivory-a:    oklch(0.97 0.012 85);
  --card-tone-ivory-b:    oklch(0.92 0.020 80);
  --card-tone-sand-a:     oklch(0.94 0.04 70);
  --card-tone-sand-b:     oklch(0.86 0.06 65);
  --card-tone-charcoal-a: oklch(0.90 0.005 60);
  --card-tone-charcoal-b: oklch(0.80 0.010 60);
  --card-tone-rose-a:     oklch(0.93 0.04 30);
  --card-tone-rose-b:     oklch(0.85 0.06 25);
  --card-tone-sage-a:     oklch(0.93 0.03 145);
  --card-tone-sage-b:     oklch(0.85 0.05 145);

  /* ── Fonts — original Claude Design spec ─────────────────────── */
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans:  "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --deva:  "Noto Sans Devanagari", var(--sans);

  /* ── Typography scale (1rem = 17px on <html>) ────────────────── */
  --fs-xs:    0.76rem;   /* 13px */
  --fs-sm:    0.88rem;   /* 15px */
  --fs-base:  1rem;      /* 17px — body */
  --fs-md:    1.12rem;   /* 19px */
  --fs-lg:    1.41rem;   /* 24px */
  --fs-xl:    1.88rem;   /* 32px */
  --fs-2xl:   2.59rem;   /* 44px */
  --fs-3xl:   3.4rem;    /* 58px — v4 hero pitch */
  --fs-4xl:   4.6rem;    /* 78px — v4 final-CTA */

  /* --fs-input: iOS focus-zoom floor — DO NOT reduce below 16px
     without re-auditing every form (covers <input>, <select>,
     <textarea>). Centralised in 2026-06-04 to retire the D5
     @media:430px override block. See
     memory/brief_realtyx_fs_input_migration.md +
     scripts/lint-fs-input.php (CI hard gate). */
  --fs-input: 16px;

  --lh-tight:    1.25;
  --lh-heading:  1.35;
  --lh-body:     1.65;
  --lh-body-hi:  1.75;

  /* ── Touch target baseline ───────────────────────────────────── */
  --tap: 48px;

  /* ── Notch / home-indicator safe-area tokens ─────────────────────
   * Centralised env(safe-area-inset-*) so the 31 historical call
   * sites collapse to four named tokens (+ three bottom-nav-clearance
   * composites for the three distinct gap shapes shipped in Phase 5
   * SRP — 12px, 14px, 16px). Defaults to 0px on non-notched devices
   * (Android / desktop / iPhone SE), so the migration is visually
   * inert outside iOS notched Safari. Adding a 5th inset in a future
   * iOS release lands as one edit here, not a 30-site sweep.
   *
   * CI drift gate: scripts/lint-no-env-safe-area.sh fails if any file
   * under public/css/ uses raw `env(safe-area-inset-*)` outside this
   * file. Once a surface lands a new safe-area need, extend the token
   * family here — never sprinkle env() at the call site. */
  --inset-top:    env(safe-area-inset-top, 0px);
  --inset-right:  env(safe-area-inset-right, 0px);
  --inset-bottom: env(safe-area-inset-bottom, 0px);
  --inset-left:   env(safe-area-inset-left, 0px);

  /* Bottom-nav clearance composites — three pre-existing gap shapes
   * (12 / 14 / 16 px). Collapsing to one would silently shrink/grow
   * the budget sheet and lean-cat menu by 2-4px each, regressing
   * Phase 5 SRP. Trade three tokens for correctness over minimalism. */
  --bottom-nav-clearance-12: calc(64px + var(--inset-bottom) + 12px);
  --bottom-nav-clearance-14: calc(14px + 64px + var(--inset-bottom));
  --bottom-nav-clearance-16: calc(64px + var(--inset-bottom) + 16px);

  /* ── v4 — matchmaker brand graft (additive, scoped to home-v4) ─
   * Editorial accent layer alongside the existing warm-neutral system.
   * Composition rule:
   *   --saffron*   = brand primary. Logo, primary buttons, ROI brand
   *                  accents, link hovers. Do not touch.
   *   --terracotta* = editorial accent. v4 Roast section, Final-CTA, pull-quote
   *                  rules, notification card border. Never on the same surface
   *                  as saffron.
   *   --moss*       = success accent for testimonials / rishta-tay copy.
   *                  Distinct from --green (form validation, data deltas).
   *   --charcoal*   = explicit dark-panel surface alias. Used by v4
   *                  persistent-profile panel; do not reuse --ink for panel
   *                  backgrounds (that token is for body text). */
  --terracotta:      oklch(0.55 0.14 35);
  --terracotta-deep: oklch(0.40 0.16 32);
  --terracotta-soft: oklch(0.94 0.05 35);
  --moss:            oklch(0.45 0.09 145);
  --moss-soft:       oklch(0.93 0.035 145);
  --cream:           oklch(0.97 0.022 80);
  --charcoal:        oklch(0.22 0.012 60);
  --charcoal-2:      oklch(0.28 0.012 60);
}

html { font-size: 17px; }

/* ── Base ──────────────────────────────────────────────────────── */
html, body {
  margin: 0;
  padding: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html[lang="hi"] body { font-family: var(--deva); line-height: var(--lh-body-hi); }

* { box-sizing: border-box; }
/* Buttons inherit BOTH font and color. Without `color: inherit`, native
 * <button>s fall back to the UA default (black) — invisible on dark
 * surfaces. Any unstyled button (e.g. .match-thumb, .match-thumbs-reason-
 * chip) now tracks the theme ink. Styled buttons (.btn*) set their own
 * color and are unaffected (their rule wins on specificity). */
button { font-family: inherit; color: inherit; }

/* ── Utility classes ───────────────────────────────────────────── */
.mono   { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: 0.02em; }
.serif  { font-family: var(--serif); }
.hi     { font-family: var(--deva); }
.italic { font-style: italic; }

.tabular, .price, .metric, .data { font-variant-numeric: tabular-nums; }

/* ── Scrollbar polish ──────────────────────────────────────────── */
::-webkit-scrollbar        { width: 10px; height: 10px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--line-2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ── Dark mode ─────────────────────────────────────────────────── */
/* Warm dark — deep brown-black base (not pure black, avoids OLED
 * halation), off-white body text, saffron brightened slightly to
 * hold its own on a dark surface.
 *
 * Variable names stay the same, so component CSS doesn't change.
 * Activation: <html data-theme="dark"> or prefers-color-scheme. */
[data-theme="dark"] {
  --ivory:        oklch(0.18 0.010 60);
  --ivory-2:      oklch(0.22 0.010 60);
  --paper:        oklch(0.25 0.010 60);
  --paper-2:      oklch(0.28 0.010 60);
  --line:         oklch(0.32 0.010 60);
  --line-2:       oklch(0.40 0.012 60);

  --ink:          oklch(0.92 0.015 85);
  --ink-2:        oklch(0.80 0.015 80);
  --ink-3:        oklch(0.66 0.012 70);
  --ink-4:        oklch(0.54 0.010 60);

  --saffron:      oklch(0.72 0.16 55);
  --saffron-deep: oklch(0.78 0.17 58);
  --saffron-soft: oklch(0.30 0.08 55);

  --green:        oklch(0.70 0.13 145);
  --green-soft:   oklch(0.28 0.10 145);
  --red:          oklch(0.68 0.17 25);
  --red-soft:     oklch(0.30 0.10 25);

  /* --accent (#c62b3f in light) is used as TEXT in several places (logout,
   * perf-down deltas, lead-time warnings). Left un-flipped it sits at ~2.6:1
   * on the dark page — fails AA. Brighten it for dark to match the --red
   * family. --accent-soft lifts to a dark tint so accent-bg chips still read. */
  --accent:       oklch(0.70 0.17 22);
  --accent-soft:  oklch(0.30 0.10 22);

  /* v4 dark — accents lift, soft tints invert, charcoal lifts ABOVE page bg
   * (0.18) so panels still read as elevated surfaces in dark mode. */
  --terracotta:      oklch(0.72 0.14 35);
  --terracotta-deep: oklch(0.78 0.16 32);
  --terracotta-soft: oklch(0.30 0.07 35);
  --moss:            oklch(0.65 0.12 145);
  --moss-soft:       oklch(0.28 0.08 145);
  --cream:           oklch(0.27 0.012 80);
  --charcoal:        oklch(0.26 0.012 60);
  --charcoal-2:      oklch(0.32 0.012 60);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    --ivory:        oklch(0.18 0.010 60);
    --ivory-2:      oklch(0.22 0.010 60);
    --paper:        oklch(0.25 0.010 60);
    --paper-2:      oklch(0.28 0.010 60);
    --line:         oklch(0.32 0.010 60);
    --line-2:       oklch(0.40 0.012 60);
    --ink:          oklch(0.92 0.015 85);
    --ink-2:        oklch(0.80 0.015 80);
    --ink-3:        oklch(0.66 0.012 70);
    --ink-4:        oklch(0.54 0.010 60);
    --saffron:      oklch(0.72 0.16 55);
    --saffron-deep: oklch(0.78 0.17 58);
    --saffron-soft: oklch(0.30 0.08 55);
    --green:        oklch(0.70 0.13 145);
    --green-soft:   oklch(0.28 0.10 145);
    --red:          oklch(0.68 0.17 25);
    --red-soft:     oklch(0.30 0.10 25);

    /* v4 dark fallback — mirrors [data-theme="dark"] block above. */
    --terracotta:      oklch(0.72 0.14 35);
    --terracotta-deep: oklch(0.78 0.16 32);
    --terracotta-soft: oklch(0.30 0.07 35);
    --moss:            oklch(0.65 0.12 145);
    --moss-soft:       oklch(0.28 0.08 145);
    --cream:           oklch(0.27 0.012 80);
    --charcoal:        oklch(0.26 0.012 60);
    --charcoal-2:      oklch(0.32 0.012 60);
  }
}

/* Smooth swap so theme toggle doesn't feel like a flash. */
html, body, .navbar, .mobile-bottom-nav, .btn, .match-pair, .post-card,
.saved-card, .broker-card, .listing-price-card, .feed-item, .intro-card,
.conversation-context-card, .deal-card, .calc-result, .broker-sidecard {
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

/* ── HTMX loading states ──────────────────────────────────────── */
.htmx-request .htmx-indicator {
  opacity: 1;
  transition: opacity 200ms ease-in;
}
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}
.htmx-request.htmx-swap-busy { cursor: progress; }
