/* PodLens design tokens.
 *
 * Ported from RentalLens's tokens.css. Single source of truth for color,
 * typography, spacing, elevation, and accessibility primitives. All
 * components.css and template-level styles consume these — never hardcoded
 * colors. Light + dark themes via `data-theme` and prefers-color-scheme.
 */

:root,
[data-theme="light"] {
  /* surfaces */
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-surface-sunken: #eef0f4;
  --color-overlay: rgba(15, 22, 36, 0.45);

  /* text */
  --color-fg: #131826;
  --color-fg-muted: #5b6478;
  --color-fg-subtle: #8b94a7;
  --color-fg-placeholder: #aab2c0;
  --color-fg-on-accent: #ffffff;

  /* accent (slate-blue) */
  --color-accent: #3c60ad;
  --color-accent-hover: #2f4f95;
  --color-accent-soft: #eef2fb;
  --color-accent-strong: #1f3771;

  /* semantic */
  --color-positive: #2f7a4d;
  --color-positive-soft: #e3f3ea;
  --color-warning: #b66f17;
  --color-warning-soft: #fbeede;
  --color-danger: #b13838;
  --color-danger-soft: #fbe6e6;
  --color-info: #2c6890;
  --color-info-soft: #e3eef7;

  /* borders / dividers */
  --color-border: #d8dde5;
  --color-border-strong: #b9c0cc;
  --color-divider: #e6e9ef;

  /* accessibility */
  --color-focus-ring: #3c60ad;
  --focus-ring-width: 2px;
  --focus-ring-offset: 2px;

  /* elevation */
  --shadow-sm: 0 1px 1px rgba(15, 22, 36, 0.04), 0 1px 2px rgba(15, 22, 36, 0.06);
  --shadow-md: 0 2px 4px rgba(15, 22, 36, 0.06), 0 4px 8px rgba(15, 22, 36, 0.06);
  --shadow-lg: 0 6px 16px rgba(15, 22, 36, 0.10);
}

[data-theme="dark"] {
  --color-bg: #0d111c;
  --color-surface: #161b29;
  --color-surface-raised: #1c2233;
  --color-surface-sunken: #0a0e18;
  --color-overlay: rgba(0, 0, 0, 0.6);

  --color-fg: #e6e9f1;
  --color-fg-muted: #97a0b3;
  --color-fg-subtle: #6c7585;
  --color-fg-placeholder: #4d5566;
  --color-fg-on-accent: #ffffff;

  --color-accent: #6f8fd6;
  --color-accent-hover: #8ba6e2;
  --color-accent-soft: #1f2a44;
  --color-accent-strong: #b8caf0;

  --color-positive: #6cc28b;
  --color-positive-soft: #163524;
  --color-warning: #d49b51;
  --color-warning-soft: #3a2a13;
  --color-danger: #e07474;
  --color-danger-soft: #3a1a1a;
  --color-info: #6fa9d3;
  --color-info-soft: #163041;

  --color-border: #2a3045;
  --color-border-strong: #3a4159;
  --color-divider: #1f2538;

  --color-focus-ring: #8ba6e2;

  --shadow-sm: 0 1px 1px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0d111c;
    --color-surface: #161b29;
    --color-surface-raised: #1c2233;
    --color-surface-sunken: #0a0e18;
    --color-overlay: rgba(0, 0, 0, 0.6);

    --color-fg: #e6e9f1;
    --color-fg-muted: #97a0b3;
    --color-fg-subtle: #6c7585;
    --color-fg-placeholder: #4d5566;
    --color-fg-on-accent: #ffffff;

    --color-accent: #6f8fd6;
    --color-accent-hover: #8ba6e2;
    --color-accent-soft: #1f2a44;
    --color-accent-strong: #b8caf0;

    --color-positive: #6cc28b;
    --color-positive-soft: #163524;
    --color-warning: #d49b51;
    --color-warning-soft: #3a2a13;
    --color-danger: #e07474;
    --color-danger-soft: #3a1a1a;
    --color-info: #6fa9d3;
    --color-info-soft: #163041;

    --color-border: #2a3045;
    --color-border-strong: #3a4159;
    --color-divider: #1f2538;

    --color-focus-ring: #8ba6e2;

    --shadow-sm: 0 1px 1px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.5);
  }
}

/* Typography & spacing — theme-independent. */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo,
    Consolas, "Liberation Mono", monospace;

  /* text — base 13px for the dense analytical feel */
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;

  --line-height-tight: 1.25;
  --line-height-base: 1.45;
  --line-height-loose: 1.65;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* spacing — 4px base scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* radii */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  /* layout dimensions (RentalLens shell) */
  --topbar-height: 48px;
  --navrail-width: 56px;
  --statusbar-height: 28px;
  --row-height: 32px;

  /* transitions */
  --transition-fast: 120ms ease-out;
  --transition-base: 180ms ease-out;
}

/* Universal :focus-visible ring tied to tokens. Components inherit. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus-ring);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-sm);
}

/* Numeric utility — monospace for confidence, counts, ticker prices. */
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Visually hidden but accessible to AT — used for icon-only nav labels. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip-to-content link, hidden until focused (Phase 4 a11y, scaffolded now). */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-2);
  z-index: 9999;
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-fg-on-accent);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
}
.skip-link:focus { top: var(--space-2); }
