/* ============================================================================
   JumpJump — Design System "Stack" — System Layer
   Tokens (OKLCH), reset, base typography. See docs/design.md.
   ============================================================================ */

/* ---------- 1. Tokens (light theme — default) ---------- */
:root {
  /* Surfaces — neutrals tinted toward brand hue 248° */
  --jj-surface:        oklch(98.0% 0.005 248);
  --jj-surface-2:      oklch(96.0% 0.007 248);
  --jj-paper:          oklch(99.5% 0.003 248);
  --jj-paper-raised:   oklch(99.7% 0.002 248);

  /* Ink */
  --jj-ink:            oklch(22% 0.015 248);
  --jj-ink-2:          oklch(42% 0.012 248);
  --jj-ink-3:          oklch(58% 0.010 248);
  --jj-ink-4:          oklch(72% 0.008 248);

  /* Rules */
  --jj-rule:           oklch(92% 0.008 248);
  --jj-rule-strong:    oklch(84% 0.012 248);

  /* Brand — saturated blue at 248° (avoids generic 220° tech-blue) */
  --jj-brand:          oklch(52% 0.16 248);
  --jj-brand-hover:    oklch(46% 0.17 248);
  --jj-brand-active:   oklch(40% 0.17 248);
  --jj-brand-soft:     oklch(96% 0.025 248);
  --jj-brand-ink:      oklch(38% 0.18 248);

  /* Semantic status */
  --jj-success:        oklch(58% 0.13 155);
  --jj-success-soft:   oklch(95% 0.03 155);
  --jj-warning:        oklch(72% 0.14 75);
  --jj-warning-soft:   oklch(96% 0.04 75);
  --jj-danger:         oklch(56% 0.18 25);
  --jj-danger-soft:    oklch(95% 0.03 25);
  --jj-info:           oklch(60% 0.13 220);
  --jj-info-soft:      oklch(95% 0.03 220);

  /* Focus */
  --jj-focus-ring:     oklch(60% 0.18 248 / 0.45);

  /* ---- Legacy aliases — keep old names pointing at new tokens ----
     Existing CSS/views still reference --jj-bone, --jj-persimmon, etc.
     These are NOT being renamed; they are remapped to the new palette
     so the cool blue system propagates everywhere automatically. */
  --jj-bone:           var(--jj-surface);
  --jj-bone-2:         var(--jj-surface-2);
  --jj-persimmon:      var(--jj-brand);
  --jj-persimmon-2:    var(--jj-brand-hover);
  --jj-persimmon-wash: var(--jj-brand-soft);
  --jj-citron:         var(--jj-warning);
  --jj-citron-2:       oklch(56% 0.16 75);
  --jj-moss:           var(--jj-success);
  --jj-rust:           var(--jj-danger);
  --jj-slate:          oklch(36% 0.04 248);

  /* Tag set (7 distinct categorical hues, harmonized chroma) */
  --tag-clay:    oklch(58% 0.14 35);
  --tag-moss:    oklch(58% 0.13 155);
  --tag-slate:   oklch(40% 0.04 248);
  --tag-citron:  oklch(70% 0.14 90);
  --tag-plum:    oklch(48% 0.14 320);
  --tag-dust:    oklch(60% 0.04 60);
  --tag-sky:     oklch(60% 0.13 220);

  /* Spacing (4px grid) */
  --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 24px;  --sp-6: 32px;  --sp-7: 48px;  --sp-8: 64px;

  /* Radius */
  --r-sharp: 2px;
  --r-soft:  6px;
  --r-pill:  999px;

  /* Shadow — subtle, cool-tinted */
  --sh-1: 0 1px 0 oklch(20% 0.015 248 / 0.05);
  --sh-2: 0 4px 12px -4px oklch(20% 0.015 248 / 0.10),
          0 2px 4px  -2px oklch(20% 0.015 248 / 0.06);
  --sh-3: 0 12px 32px -8px oklch(20% 0.015 248 / 0.18),
          0 4px 8px  -4px oklch(20% 0.015 248 / 0.08);
  --sh-focus: 0 0 0 3px var(--jj-focus-ring);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --d-fast:   120ms;
  --d-base:   160ms;
  --d-slow:   240ms;

  /* Type tokens — escala com contraste real entre degraus (ver DESIGN.md).
     Papeis: xs=metadado/chip, sm=label/hint, md=corpo base da UI (card/tabela/input),
     base=leitura, lg=subtitulo/painel, xl=titulo secundario, 2xl=titulo de tela,
     3xl=hero de secao, 4xl/display=landing. */
  /* Em rem (ancorado a 16px) p/ escalar via font-size do <html> — ver FontScale.cs.
     Comentário = equivalente em px no nível padrão (root 100% = 16px). */
  --t-xs:      0.6875rem; /* 11px */
  --t-sm:      0.75rem;   /* 12px */
  --t-md:      0.8125rem; /* 13px */
  --t-base:    0.875rem;  /* 14px */
  --t-lg:      1rem;      /* 16px */
  --t-xl:      1.1875rem; /* 19px */
  --t-2xl:     1.4375rem; /* 23px */
  --t-3xl:     1.75rem;   /* 28px */
  --t-4xl:     2.125rem;  /* 34px */
  --t-display: 2.875rem;  /* 46px */

  --lh-tight:  1.2;
  --lh-snug:   1.4;
  --lh-base:   1.5;
  --lh-loose:  1.7;

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  --ls-uppercase: 0.08em;

  /* Layout dimensions */
  --jj-sidebar-w-collapsed: 64px;
  --jj-sidebar-w-expanded:  220px;
  --jj-topbar-h:            48px;
  --jj-modal-z:             1050;
  --jj-popover-z:           1040;
  --jj-toast-z:             1080;
  --jj-cmdk-z:              1090;
}

/* ---------- 2. Dark theme (Slate Night) ---------- */
[data-theme="dark"] {
  --jj-surface:        oklch(20% 0.012 248);
  --jj-surface-2:      oklch(17% 0.010 248);
  --jj-paper:          oklch(24% 0.014 248);
  --jj-paper-raised:   oklch(28% 0.014 248);

  --jj-ink:            oklch(95% 0.006 248);
  --jj-ink-2:          oklch(80% 0.008 248);
  --jj-ink-3:          oklch(64% 0.010 248);
  --jj-ink-4:          oklch(48% 0.012 248);

  --jj-rule:           oklch(34% 0.012 248);
  --jj-rule-strong:    oklch(42% 0.014 248);

  --jj-brand:          oklch(70% 0.15 248);
  --jj-brand-hover:    oklch(76% 0.14 248);
  --jj-brand-active:   oklch(80% 0.13 248);
  --jj-brand-soft:     oklch(32% 0.06 248);
  --jj-brand-ink:      oklch(85% 0.10 248);

  --jj-success:        oklch(70% 0.13 155);
  --jj-success-soft:   oklch(30% 0.06 155);
  --jj-warning:        oklch(80% 0.14 75);
  --jj-warning-soft:   oklch(32% 0.06 75);
  --jj-danger:         oklch(68% 0.17 25);
  --jj-danger-soft:    oklch(30% 0.07 25);
  --jj-info:           oklch(72% 0.13 220);
  --jj-info-soft:      oklch(30% 0.06 220);

  --jj-focus-ring:     oklch(72% 0.18 248 / 0.55);

  --jj-slate:          oklch(70% 0.04 248);

  /* Tag hues — slightly lighter for dark surfaces */
  --tag-clay:    oklch(70% 0.14 35);
  --tag-moss:    oklch(70% 0.13 155);
  --tag-slate:   oklch(70% 0.04 248);
  --tag-citron:  oklch(80% 0.14 90);
  --tag-plum:    oklch(64% 0.14 320);
  --tag-dust:    oklch(72% 0.04 60);
  --tag-sky:     oklch(72% 0.13 220);

  --sh-1: 0 1px 0 oklch(0% 0 0 / 0.20);
  --sh-2: 0 4px 12px -4px oklch(0% 0 0 / 0.40),
          0 2px 4px  -2px oklch(0% 0 0 / 0.25);
  --sh-3: 0 12px 32px -8px oklch(0% 0 0 / 0.55),
          0 4px 8px  -4px oklch(0% 0 0 / 0.30);
}

/* ---------- 3. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

html {
  /* Pivô da escala de fonte. 100% = 16px (default do browser). A escala por usuário
     sobrescreve isto via style inline no <html> (server-render, anti-FOUC) — ver
     _Layout.cshtml e FontScale.cs. Tudo em rem escala junto. */
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter Tight', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--t-base);
  line-height: var(--lh-base);
  font-feature-settings: "tnum", "ss01";
  color: var(--jj-ink-2);
  background: var(--jj-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background var(--d-base) var(--ease), color var(--d-base) var(--ease);
}

img, svg { max-width: 100%; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: var(--jj-brand);
  text-decoration: none;
  transition: color var(--d-fast) var(--ease);
}
a:hover { color: var(--jj-brand-hover); }

ul, ol { padding-left: 1.25em; }
ul.unstyled, ol.unstyled { list-style: none; padding-left: 0; margin: 0; }

hr {
  border: 0;
  border-top: 1px solid var(--jj-rule);
  margin: var(--sp-4) 0;
}

/* ---------- 4. Typography helpers (sans-serif throughout) ---------- */
.jj-display {
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-weight: var(--fw-semibold);
  font-size: var(--t-display);
  line-height: 1.05;
  color: var(--jj-ink);
  letter-spacing: -0.02em;
}
.jj-headline {
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-weight: var(--fw-semibold);
  font-size: var(--t-3xl);
  line-height: var(--lh-tight);
  color: var(--jj-ink);
  letter-spacing: -0.01em;
}
.jj-h1 { font-size: var(--t-4xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); color: var(--jj-ink); margin: 0; letter-spacing: -0.015em; }
.jj-h2 { font-size: var(--t-3xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); color: var(--jj-ink); margin: 0; letter-spacing: -0.01em; }
.jj-h3 { font-size: var(--t-2xl); font-weight: var(--fw-semibold); line-height: var(--lh-snug); color: var(--jj-ink); margin: 0; }
.jj-h4 { font-size: var(--t-xl);  font-weight: var(--fw-semibold); line-height: var(--lh-snug); color: var(--jj-ink); margin: 0; }

.jj-kicker {
  font-size: var(--t-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ls-uppercase);
  color: var(--jj-ink-3);
}
.jj-meta { font-size: var(--t-sm); color: var(--jj-ink-3); }
.jj-mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; font-feature-settings: "tnum"; }
.jj-quote {
  font-family: 'Inter Tight', system-ui, sans-serif;
  font-weight: var(--fw-regular);
  color: var(--jj-ink-2);
  border-left: 2px solid var(--jj-rule-strong);
  padding-left: var(--sp-3);
}

/* ---------- 5. Lucide icon overrides ---------- */
[data-lucide] {
  stroke-width: 1.5 !important;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  color: currentColor;
  flex-shrink: 0;
}

.jj-icon-14 { width: 14px; height: 14px; }
.jj-icon-16 { width: 16px; height: 16px; }
.jj-icon-20 { width: 20px; height: 20px; }
.jj-icon-24 { width: 24px; height: 24px; }
.jj-icon-40 { width: 40px; height: 40px; }

/* ---------- 6. Focus — outline ring (modern, a11y-friendly) ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--jj-focus-ring);
  outline-offset: 2px;
  border-radius: var(--r-soft);
}

/* ---------- 7. Selection ---------- */
::selection { background: var(--jj-brand-soft); color: var(--jj-ink); }

/* ---------- 8. Scrollbar (subtle) ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--jj-rule-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--jj-rule-strong);
  border-radius: var(--r-pill);
}
*::-webkit-scrollbar-thumb:hover { background: var(--jj-ink-3); }

/* ---------- 9. Visually hidden ---------- */
.visually-hidden, .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;
}

/* ---------- 10. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 11. Containers ---------- */
.jj-container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
}
.jj-container--narrow { max-width: 720px; }
.jj-container--wide   { max-width: 1440px; }

/* ---------- 12. Version badge ---------- */
/* Discreto, fixo no canto inferior direito, em todas as páginas. */
.jj-version-badge {
  position: fixed;
  right: 8px;
  bottom: 6px;
  z-index: 9999;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: rgba(127, 127, 127, 0.55);
  pointer-events: none;
  user-select: none;
  background: transparent;
  padding: 2px 4px;
}
@media (max-width: 480px) {
  .jj-version-badge { font-size: 9px; right: 4px; bottom: 4px; }
}
