/**
 * Resaneh Design Tokens — MVP-004 (v0.4.0), WBS Tasks 7-8.
 *
 * Implements ONLY values already approved in docs/DESIGN_SYSTEM.md
 * SS1-SS4 (DESIGN-A.1/A.2/A.3) plus the ADM-P3 owner ruling of
 * 13 September 2026. Nothing here invents a semantic-state palette
 * (ADM-P1, deferred), a categorical/chart palette (ADM-P2, deferred),
 * or a spacing/radius/elevation scale (explicitly "Not decided", SS6).
 *
 * All colour and type values are expressed as custom properties so a
 * future dark theme (D-41: light-mode only for this MVP roadmap) can
 * be introduced without a redesign.
 *
 * Font files are self-hosted WOFF2 (D-42), pinned at Fontsource 5.3.0,
 * itself built from IBM's official upstream IBM Plex distribution.
 * Weights 400/500/600 only - 700 is OUT per D-42. No runtime Google
 * Fonts or other font CDN is used anywhere in this file.
 */

:root {
  /* ---- Brand (D-34) ---------------------------------------------- */
  --brand-core: #960546;

  /* Derived interaction states (ADM-P3, ruled 13 Sep 2026): the
     smallest accessible extension the interactive states require.
     Hue held at 333 deg per SS2.1; lightness only. Both steps were
     verified >= 7:1 against white text, comfortably clearing the
     4.5:1 WCAG 2.2 AA text/background threshold used for a filled
     button. No tint ramp, no visited-link colour, no focus-ring
     colour is introduced here - those remain unfrozen (SS6). */
  --brand-core-hover: #780438;
  --brand-core-pressed: #5b032a;

  /* ---- Grounds (D-36) ---------------------------------------------*/
  --surface-canvas: #ffffff;
  --surface-subtle: #fbf9f8;
  --surface-warm: #f8f6f3;
  --surface-premium: #d8c1a5;

  /* ---- Category Heatmap semantic colours --------------------------
     OWNER AMENDMENT, 22 September 2026. Registered in
     docs/DESIGN_SYSTEM.md §2.8 and §11.3a; derivation and banding in
     docs/tasks/TASK-MVP-013.md §9.5.

     These three express the RENDERED RANK band under the ACTIVE Sort on
     the Category page's Ranked Business Heatmap, and carry no meaning on
     any other surface. They supersede the Editorial Cream ramp for that
     heatmap's tile fill and for nothing else.

     --surface-heat-low REFERENCES --surface-warm. #F8F6F3 already exists
     in the approved palette as the warm ground (D-36) and must not be
     given a second global definition; the reference is the whole point.
     Note the naming trap this avoids: --surface-canvas is #FFFFFF, and
     the tone often called the Resaneh canvas is --surface-warm.

     NOT promoted to a general Design System role: §11.9's unfrozen
     register is unchanged, and no other component may cite these. */
  --surface-heat-high: #faefe6;
  --surface-heat-mid: #f0f0ed;
  --surface-heat-low: var(--surface-warm);

  /* ---- Neutral ramp (D-37) ---------------------------------------*/
  --fill-hover: #f5f3f1;
  --divider: #ebe9e4;
  --border-container: #dcd8d1;
  --border-interactive: #978b7a; /* also the approved Premium boundary, D-38 */
  --text-muted: #776e60;
  --text-secondary: #585148;
  --text-strong: #3f3932;
  --text-primary: #22211e;

  /* ---- Typography (D-42) ------------------------------------------*/
  --font-latin: 'IBM Plex Sans', -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-persian: 'IBM Plex Sans Arabic', Tahoma, sans-serif;

  /* Editorial type scale (D-46) - EN px / FA px, EN lh / FA lh, weight 600
     unless noted. Exposed as paired custom properties; utilities.css
     supplies the [lang] switch (SS4.4 "Governing rule": each tier's
     values are measured per script, never derived by a universal rule). */
  --type-display-size-en: 42px;   --type-display-size-fa: 42px;
  --type-display-lh-en: 1.14;     --type-display-lh-fa: 1.40;
  --type-h1-size-en: 33px;        --type-h1-size-fa: 33px;
  --type-h1-lh-en: 1.20;          --type-h1-lh-fa: 1.45;
  --type-h2-size-en: 26px;        --type-h2-size-fa: 26px;
  --type-h2-lh-en: 1.25;          --type-h2-lh-fa: 1.50;
  --type-h3-size-en: 21px;        --type-h3-size-fa: 22px;
  --type-h3-lh-en: 1.35;          --type-h3-lh-fa: 1.60;
  --type-lead-size-en: 21px;      --type-lead-size-fa: 22px;
  --type-lead-lh-en: 1.60;        --type-lead-lh-fa: 1.85;
  --type-body-size-en: 17px;      --type-body-size-fa: 18px;
  --type-body-lh-en: 1.75;        --type-body-lh-fa: 1.90;
  --type-small-size-en: 14px;     --type-small-size-fa: 15px;
  --type-small-lh-en: 1.55;       --type-small-lh-fa: 1.75;
  --type-micro-size-en: 13px;     --type-micro-size-fa: 14px;
  --type-micro-lh-en: 1.40;       --type-micro-lh-fa: 1.65;

  /* Directory density variant (D-48) */
  --type-card-title-size-en: 19px; --type-card-title-size-fa: 20px;
  --type-card-title-lh-en: 1.30;   --type-card-title-lh-fa: 1.55;
  --type-dir-body-size-en: 16px;   --type-dir-body-size-fa: 17px;
  --type-dir-body-lh-en: 1.60;     --type-dir-body-lh-fa: 1.75;
  --type-metadata-size-en: 13px;   --type-metadata-size-fa: 14px;
  --type-metadata-lh-en: 1.45;     --type-metadata-lh-fa: 1.70;
  --type-chip-size-en: 12px;       --type-chip-size-fa: 13px;
  --type-chip-lh-en: 1.35;         --type-chip-lh-fa: 1.60;

  /* Editorial measure (D-47) */
  --measure-en: 33rem;   /* 528px */
  --measure-fa: 31.5rem; /* 504px */
}

/* ------------------------------------------------------------------
 * Self-hosted webfonts (D-42). No unicode-range hack that would defer
 * loading a script the page is about to render - both families load
 * together because mixed-direction content (SS4) means an English
 * phone number or price can appear on an otherwise-Persian page and
 * vice versa. 700 Bold is intentionally absent (D-42: "OUT").
 * ------------------------------------------------------------------ */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-latin-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-latin-600.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/ibm-plex-sans-arabic-600.woff2') format('woff2');
}

/* ED-3 (DESIGN_SYSTEM.md §13.2) — the ONE scoped typeface exception: the
 * Editorial Display headline, and nothing else, is Noto Serif (Latin) and
 * Noto Naskh Arabic (Persian). SIL OFL 1.1, self-hosted WOFF2, weight 600
 * only (700 remains OUT). Arrives with MVP-014, as the Release-1 roadmap
 * records. Declaring a face downloads nothing: only a page that renders
 * `.ed-display` fetches either file. Files: the fontsource 5.3.0 `latin`
 * and `arabic` subsets of the upstream Noto fonts. */
@font-face {
  font-family: 'Noto Serif';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/noto-serif-latin-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Noto Naskh Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/noto-naskh-arabic-600.woff2') format('woff2');
}

/* ------------------------------------------------------------------
 * Base document typography, driven by [dir]/[lang] on <html> (main.php
 * already supplies both per request from the resolved Locale). Bootstrap
 * variables are not overridden here (SS8: no approved components yet) -
 * only the raw body font stack and colour, which every page inherits.
 * ------------------------------------------------------------------ */
html[lang='fa'],
html[dir='rtl'] {
  font-family: var(--font-persian);
}
html[lang='en'],
html[dir='ltr'] {
  font-family: var(--font-latin);
}

body {
  background-color: var(--surface-canvas);
  color: var(--text-primary);
  font-family: var(--font-latin);
  font-size: var(--type-body-size-en);
  line-height: var(--type-body-lh-en);
}
html[lang='fa'] body {
  font-family: var(--font-persian);
  font-size: var(--type-body-size-fa);
  line-height: var(--type-body-lh-fa);
}

/* Responsive floor for any embedded raster or vector image, matching the
 * project's existing img{max-width:100%} convention - without it an
 * inline SVG's own width="" attribute (the P8 assets carry one, per
 * their production-master viewBox) establishes its own box regardless
 * of its wrapper's CSS width, which is what caused horizontal overflow
 * of the brand-asset frames at every breakpoint before this rule. */
img,
svg {
  max-width: 100%;
  height: auto;
}

/* ADM-P3: brand-core hover/pressed applied to the one interactive
 * primitive this Build introduces - inline links (D-39) and the
 * generic .btn-brand utility demonstrated on /style-guide. No other
 * component exists to carry these states yet (SS8: "None. Populated
 * as each is implemented from an approved mockup"). */
a {
  color: var(--brand-core);
  text-decoration: underline; /* D-39: structural, not stylistic - brand-core
                                  measures 1.83:1 against body text, below the
                                  3:1 WCAG 1.4.1 floor for colour-only cues */
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover {
  color: var(--brand-core-hover);
}
a:active {
  color: var(--brand-core-pressed);
}

.btn-brand {
  display: inline-block;
  background-color: var(--brand-core);
  color: #ffffff;
  border: 1px solid var(--brand-core);
  border-radius: 0.25rem; /* Bootstrap's own default - SS6 radius scale is
                              unfrozen, so no Resaneh-specific value is
                              introduced; this borrows Bootstrap's, which
                              the site already loads. */
  padding-inline: 1rem;
  padding-block: 0.5rem;
  text-decoration: none;
}
.btn-brand:hover {
  background-color: var(--brand-core-hover);
  border-color: var(--brand-core-hover);
  color: #ffffff;
}
.btn-brand:active,
.btn-brand.is-pressed {
  background-color: var(--brand-core-pressed);
  border-color: var(--brand-core-pressed);
  color: #ffffff;
}
.btn-brand:focus-visible {
  outline: 2px solid var(--brand-core-pressed);
  outline-offset: 2px;
}
