/* ═══════════════════════════════════════════════════════════════
   SENSHIN TYPOGRAPHY — CANONICAL
   Consumes design-tokens.css. DO NOT hard-code font-size or
   font-weight values here or anywhere else.
   See design-tokens.css for the full rules and rationale.
   ═══════════════════════════════════════════════════════════════ */

/* ── Base ─────────────────────────────────────────────────────── */

html {
  font-size: var(--fs-base);  /* 14px anchor */
}

body {
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── Headings ─────────────────────────────────────────────────── */

h1 { font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: -0.01em; }
h3 { font-size: var(--fs-xl);  font-weight: var(--fw-bold); line-height: var(--lh-tight); }
h4 { font-size: var(--fs-lg);  font-weight: var(--fw-semibold); line-height: var(--lh-normal); }
h5 { font-size: var(--fs-base);font-weight: var(--fw-semibold); line-height: var(--lh-normal); }
h6 { font-size: var(--fs-small); font-weight: var(--fw-semibold); line-height: var(--lh-normal); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Utility classes ──────────────────────────────────────────── */

.text-caption { font-size: var(--fs-caption); }
.text-small   { font-size: var(--fs-small); }
.text-body    { font-size: var(--fs-body); }
.text-base    { font-size: var(--fs-base); }
.text-lg      { font-size: var(--fs-lg); }
.text-xl      { font-size: var(--fs-xl); }
.text-2xl     { font-size: var(--fs-2xl); }
.text-3xl     { font-size: var(--fs-3xl); }

.fw-regular  { font-weight: var(--fw-regular); }
.fw-semibold { font-weight: var(--fw-semibold); }
.fw-bold     { font-weight: var(--fw-bold); }

small, .text-sm { font-size: var(--fs-small); }
.text-xs { font-size: var(--fs-caption); }

/* ── Form controls ────────────────────────────────────────────── */

input, select, textarea, button {
  font-size: var(--fs-base);
  font-family: inherit;
  font-weight: var(--fw-regular);
}

button, .btn, .ss-btn {
  font-weight: var(--fw-semibold);
}

/* ── Tables ───────────────────────────────────────────────────── */

th, td {
  font-size: var(--fs-body);
}

th {
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Metrics and data display ─────────────────────────────────── */

.metric-value, .ss-metric__value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  line-height: 1;
}

.metric-label, .ss-metric__label {
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t3, #6b6b67);
}

/* ═══════════════════════════════════════════════════════════════
   RETROACTIVE READABILITY FLOOR
   Targets common legacy classes across the app that were built
   before the canonical scale. Uses !important to clamp any
   stray 9px / 10px / half-pixel / 500wt / 800wt inherited from
   inline styles or older component CSS.
   Only applies to classes — inline style="font-size:10px" wins
   at equal specificity, which is why we also sweep inline styles
   in app-shell-vnext.html and the pages_vnext/*.js files.
   ═══════════════════════════════════════════════════════════════ */

.pill,
.ss-pill,
.ss-metric__label,
.ss-metric__meta,
.ss-section-lbl,
.ss-group__label,
.ss-group__footer,
.ss-group-row--edit .ss-group-row__label,
.ss-table th,
.ss-th-sort,
.ss-th-sort__arrow,
.ss-field-label,
.ss-card-row__line--meta,
.ss-card-row__raid,
.nav__group,
.nav__badge,
.nav__user-credits,
.header__crumb,
.header__sep,
.mobile-tab__lbl,
.mobile-more__item span,
.ai-nudge__label,
.ai-nudge__num,
.ai-source,
.sv-source,
.tp-tab-badge,
.vh-badge,
.ar-gstat-lbl,
.ar-ai-badge,
.conflict-badge,
.guest-item__badge,
.rm-group-label,
.fin-table th,
.fin-cat-lines th,
.prj-nudge-lbl,
.prj-section-lbl,
.prj-status-badge,
.pd-phase-gate,
.dd-plan {
  font-size: var(--fs-caption) !important;
}

/* Weight clamp — any stray 800 or 500 falls to the canonical ramp */
.pill, .ss-pill, .ss-metric__label, .ss-section-lbl,
.ss-table th, .ss-field-label, .ss-group__label,
.nav__group, th {
  font-weight: var(--fw-semibold) !important;
}

/* Small-body elements that should be 12px, not 10-11px */
.ss-card-row__line,
.ss-card-row__line--meta,
.ss-group__footer,
.header__crumb,
.header__sep,
.dd-plan {
  font-size: var(--fs-small) !important;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — PHONE
   iOS zooms form inputs when font-size < 16px. Lift inputs to
   --fs-lg (16px) on phones. Lift body-ish secondary text a half
   notch so it stays readable at arm's length.
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 767px), (hover: none) and (pointer: coarse) {
  html {
    font-size: var(--fs-base);
  }
  body {
    font-size: var(--fs-base);
  }
  /* Anti-zoom on iOS: inputs must be ≥ 16px */
  input, select, textarea {
    font-size: var(--fs-lg) !important;
  }
  /* Caption floor lifts by one step on phone */
  .ss-metric__label,
  .ss-section-lbl,
  .ss-group__label,
  .ss-table th,
  .pill,
  .ss-pill,
  .metric-label,
  .nav__group,
  th {
    font-size: var(--fs-small) !important;
  }
  /* Body-secondary text lifts to base on phone */
  .ss-card-row__line,
  .ss-card-row__line--meta,
  .header__crumb,
  .dd-plan {
    font-size: var(--fs-body) !important;
  }
}

/* ── Tablet ──────────────────────────────────────────────────────
   iPad portrait/landscape: same scale as desktop. No changes. */

/* ═══════════════════════════════════════════════════════════════
   LEGACY COMPATIBILITY
   Old var names used by a handful of components. Re-pointed to
   canonical tokens so removing them doesn't break anything.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --type-base: var(--fs-base);
  --type-xs:   var(--fs-caption);
  --type-sm:   var(--fs-small);
  --type-md:   var(--fs-base);
  --type-lg:   var(--fs-lg);
  --type-xl:   var(--fs-xl);
  --type-2xl:  var(--fs-2xl);
  --type-3xl:  var(--fs-3xl);
  --line-tight:   var(--lh-tight);
  --line-normal:  var(--lh-normal);
  --line-relaxed: var(--lh-relaxed);
}
