/* ========================================================================
   KarPayi Typography System — Rucent + Bootstrap 5.3
   GitLab-inspired clarity: large headings, confident weights, clean body.
   Load AFTER bootstrap.min.css, BEFORE design-tokens.css
   ======================================================================== */

/* --- @font-face declarations ------------------------------------------ */
@font-face {
  font-family: 'Rucent';
  src: url('/assets/fonts/Rucent-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Rucent';
  src: url('/assets/fonts/Rucent-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Rucent';
  src: url('/assets/fonts/Rucent-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Rucent';
  src: url('/assets/fonts/Rucent-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
/* Bold mapped to SemiBold (no Bold weight file available) */
@font-face {
  font-family: 'Rucent';
  src: url('/assets/fonts/Rucent-SemiBold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* =====================================================================
   TYPE SCALE TOKENS

   Rucent optically light → compensate with:
   - Larger base (15–16px instead of 14–16px)
   - More aggressive heading scale (major third ~1.25)
   - Heavier default weights (body 450-ish via medium on key elements)
   - Tighter heading letter-spacing for density
   ===================================================================== */
:root {
  /* Font family */
  --kp-font: 'Rucent', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Responsive font sizes — major third scale ~1.25
     Bumped minimums: mobile body starts at 15px not 14px */
  --fs-xs:   clamp(0.75rem,  0.72rem + 0.12vw,  0.8125rem);  /* 12–13px */
  --fs-sm:   clamp(0.8125rem, 0.79rem + 0.15vw, 0.9375rem);  /* 13–15px */
  --fs-base: clamp(0.9375rem, 0.9rem + 0.2vw,   1rem);       /* 15–16px */
  --fs-lg:   clamp(1.0625rem, 1rem + 0.3vw,     1.1875rem);   /* 17–19px */
  --fs-xl:   clamp(1.25rem,   1.15rem + 0.4vw,  1.5rem);      /* 20–24px */
  --fs-2xl:  clamp(1.5rem,    1.35rem + 0.65vw, 1.875rem);    /* 24–30px */
  --fs-3xl:  clamp(1.875rem,  1.65rem + 0.9vw,  2.5rem);      /* 30–40px */
  --fs-4xl:  clamp(2.25rem,   1.95rem + 1.25vw, 3.25rem);     /* 36–52px */

  /* Line heights */
  --lh-tight:   1.15;
  --lh-snug:    1.25;
  --lh-normal:  1.55;
  --lh-relaxed: 1.7;

  /* Letter spacing — tighter headings for GitLab-like density */
  --ls-tight:  -0.02em;
  --ls-snug:   -0.01em;
  --ls-normal: 0;
  --ls-wide:   0.01em;
  --ls-wider:  0.025em;
  --ls-caps:   0.06em;

  /* Font weights */
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;   /* maps to SemiBold woff2 — heaviest available */

  /* Bootstrap overrides */
  --bs-font-sans-serif: var(--kp-font);
  --bs-body-font-family: var(--kp-font);
  --bs-body-font-size: var(--fs-base);
  --bs-body-line-height: var(--lh-normal);
}

/* =====================================================================
   BASE BODY
   ===================================================================== */
body {
  font-family: var(--kp-font);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-normal);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* =====================================================================
   HEADINGS — Bold, tight, confident (GitLab-inspired)
   ===================================================================== */
h1, .h1 {
  font-size: var(--fs-4xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
}
h2, .h2 {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
}
h3, .h3 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-snug);
}
h4, .h4 {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-snug);
}
h5, .h5 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-normal);
}
h6, .h6 {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

/* =====================================================================
   PARAGRAPH & SMALL TEXT
   ===================================================================== */
.lead {
  font-size: var(--fs-lg);
  font-weight: var(--fw-regular);
  line-height: var(--lh-relaxed);
  color: var(--text-2, #4b5563);
}
small, .small, .text-sm {
  font-size: var(--fs-sm);
}
.text-xs {
  font-size: var(--fs-xs);
}
.text-lg {
  font-size: var(--fs-lg);
}

/* =====================================================================
   NUMERIC TYPOGRAPHY — Fintech Precision
   ===================================================================== */

/* Global numeric mode (add class to <body>) */
.numeric-global {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Component-scoped numeric classes (preferred) */
.num,
.kpi-number,
.price,
.rate,
.ticker,
.id-code {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* KPI / stat numbers — large, bold, mono-width */
.kpi-number {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
}

/* Prices — semibold, standard size */
.price {
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-normal);
}
.price-lg {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Rates — medium weight, aligned columns */
.rate {
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
}

/* Ticker / streaming values */
.ticker {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  letter-spacing: var(--ls-wide);
}

/* ID codes, IBAN, reference numbers */
.id-code {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wider);
}

/* Percent change badges */
.pct-change {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
}

/* =====================================================================
   TABLE TYPOGRAPHY
   ===================================================================== */

.table th,
.table td {
  font-size: var(--fs-sm);
  vertical-align: middle;
}
.table thead th {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-2, #4b5563);
}
/* Numeric columns: right-align + tabular figures */
.table .col-num,
.table td.col-num,
.table th.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-weight: var(--fw-medium);
}

/* =====================================================================
   FORM TYPOGRAPHY
   ===================================================================== */

.form-control,
.form-select {
  font-family: var(--kp-font);
  font-size: var(--fs-base);
}
.form-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
}
/* Number inputs — tabular figures for aligned decimals */
input[type="number"],
.form-control.num-input {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* =====================================================================
   BUTTON TYPOGRAPHY
   ===================================================================== */

.btn {
  font-family: var(--kp-font);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  letter-spacing: var(--ls-wide);
  text-transform: none;
}
.btn-sm {
  font-size: var(--fs-xs);
}
.btn-lg {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
}

/* =====================================================================
   BADGE & LABEL TYPOGRAPHY
   ===================================================================== */

.badge {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
}
