@import 'tailwindcss';
@import '@fontsource-variable/literata';
@import '@fontsource-variable/public-sans';

/*
 * Justice Choice design tokens
 * Paper (cool) · Ink (slate) · Ledger green (verification, primary actions) · Brass (rank numerals)
 * Score-ledger families: expertise (greens), standing (brass), data quality (slate)
 */
:root {
  --paper: #f5f7f4;
  --surface: #ffffff;
  --sunken: #edf0ec;
  --raised: #fbfcfa;
  --ink: #172026;
  --ink-2: #3b464d;
  --muted: #5e6a70;
  --rule: #d8ddd7;
  --rule-strong: #b9c1ba;
  --ledger: #1e4d3f;
  --ledger-hover: #173f33;
  --ledger-press: #12332a;
  --ledger-ink: #ffffff;
  --ledger-soft: #e3eee9;
  --ledger-tint: #f0f6f3;
  --brass: #96691f;
  --brass-soft: #f4ecdc;
  --sponsor: #5f4b8b;
  --sponsor-soft: #f1eef8;
  --danger: #a33a2c;
  --danger-soft: #fbecea;
  --warn: #8a5a00;
  --focus: #2f7d64;

  --shadow-xs: 0 1px 2px rgb(23 32 38 / 0.06);
  --shadow-sm: 0 1px 2px rgb(23 32 38 / 0.05), 0 2px 6px rgb(23 32 38 / 0.05);
  --shadow-md: 0 2px 4px rgb(23 32 38 / 0.04), 0 8px 24px rgb(23 32 38 / 0.08);
  --shadow-lg: 0 4px 8px rgb(23 32 38 / 0.05), 0 20px 48px rgb(23 32 38 / 0.14);
  --header-h: 4rem;

  /* Score-ledger groups — validated (lightness, chroma, CVD, contrast) against the light surface */
  --g-expertise: #18805a;
  --g-standing: #b8801c;
  --g-service: #2f6fb8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12181b;
    --surface: #182024;
    --sunken: #0e1416;
    --raised: #1d272c;
    --ink: #e8ece9;
    --ink-2: #c3cbc6;
    --muted: #93a19b;
    --rule: #2a3439;
    --rule-strong: #3b484e;
    --ledger: #6cc3a0;
    --ledger-hover: #82d0b0;
    --ledger-press: #5ab38f;
    --ledger-ink: #0d1a15;
    --ledger-soft: #1b2e27;
    --ledger-tint: #172520;
    --brass: #e0b35f;
    --brass-soft: #2b2416;
    --sponsor: #b9a6e6;
    --sponsor-soft: #241f33;
    --danger: #f08a7a;
    --danger-soft: #2e1c19;
    --warn: #e7b85a;
    --focus: #6cc3a0;
    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3), 0 2px 6px rgb(0 0 0 / 0.2);
    --shadow-md: 0 2px 4px rgb(0 0 0 / 0.25), 0 8px 24px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 4px 8px rgb(0 0 0 / 0.3), 0 20px 48px rgb(0 0 0 / 0.5);
    /* Selected dark steps, validated against the dark surface */
    --g-expertise: #26a072;
    --g-standing: #b88220;
    --g-service: #5a92e0;
  }
}

@theme inline {
  --color-paper: var(--paper);
  --color-surface: var(--surface);
  --color-sunken: var(--sunken);
  --color-raised: var(--raised);
  --color-ink: var(--ink);
  --color-ink-2: var(--ink-2);
  --color-muted: var(--muted);
  --color-rule: var(--rule);
  --color-rule-strong: var(--rule-strong);
  --color-ledger: var(--ledger);
  --color-ledger-hover: var(--ledger-hover);
  --color-ledger-ink: var(--ledger-ink);
  --color-ledger-soft: var(--ledger-soft);
  --color-ledger-tint: var(--ledger-tint);
  --color-brass: var(--brass);
  --color-brass-soft: var(--brass-soft);
  --color-sponsor: var(--sponsor);
  --color-sponsor-soft: var(--sponsor-soft);
  --color-danger: var(--danger);
  --color-danger-soft: var(--danger-soft);
  --color-warn: var(--warn);
  --color-focus: var(--focus);
  --font-serif: 'Literata Variable', 'Iowan Old Style', Georgia, serif;
  --font-sans: 'Public Sans Variable', ui-sans-serif, system-ui, sans-serif;
  --shadow-xs: var(--shadow-xs);
  --shadow-sm: var(--shadow-sm);
  --shadow-md: var(--shadow-md);
  --shadow-lg: var(--shadow-lg);
}

@layer base {
html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
  -webkit-text-size-adjust: 100%;
}
body {
  background: var(--paper);
  font-size: 14px;
  line-height: 1.55;
}
h1,
h2,
h3,
h4 {
  text-wrap: balance;
  line-height: 1.2;
}
p,
li,
dd {
  text-wrap: pretty;
}
::selection {
  background: var(--ledger-soft);
  color: var(--ink);
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
a {
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition:
    color 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    text-decoration-color 140ms ease;
}
button,
summary,
[role='option'],
label:has(input[type='checkbox']) {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
}
input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--ledger);
  width: 1rem;
  height: 1rem;
}
summary::-webkit-details-marker {
  display: none;
}
}

/* Scrollbars are hidden console-wide (unlayered so nothing overrides it);
   wheel, touch, keyboard and trackpad scrolling still work */
html,
body,
* {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}
::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.num {
  font-variant-numeric: tabular-nums lining-nums;
}

/* Long-form text from editorial content */
.prose-legal p {
  margin: 0 0 1em;
  max-width: 68ch;
}
.prose-legal p:last-child {
  margin-bottom: 0;
}

/* Rank numeral — the brass serif figure that anchors each ranked row */
.rank-figure {
  font-family: var(--font-serif);
  font-variation-settings: 'opsz' 72;
  font-weight: 500;
  color: var(--brass);
  font-variant-numeric: lining-nums;
  line-height: 1;
}

/* Component classes live in the components layer so Tailwind utilities on the same element win */
@layer components {
/* ───────────── Form fields */
.field {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  line-height: 1.4;
  box-shadow: var(--shadow-xs);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}
.field::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
.field:hover:not(:disabled):not(:focus) {
  border-color: var(--muted);
}
.field:focus,
.field:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
.field[aria-invalid='true'] {
  border-color: var(--danger);
}
.field[aria-invalid='true']:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent);
}
.field:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
textarea.field {
  resize: vertical;
  min-height: 6rem;
}
select.field {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235e6a70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 1rem;
}
.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

/* ───────────── Buttons — hover lifts colour, active presses, focus rings, disabled dims */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease,
    transform 80ms ease;
}
.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  pointer-events: none;
}
.btn-primary {
  background: var(--ledger);
  color: var(--ledger-ink);
  box-shadow:
    var(--shadow-xs),
    inset 0 1px 0 rgb(255 255 255 / 0.08);
}
.btn-primary:hover {
  background: var(--ledger-hover);
  box-shadow: var(--shadow-sm);
}
.btn-primary:active {
  background: var(--ledger-press);
}
.btn-quiet {
  border-color: var(--rule-strong);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.btn-quiet:hover {
  background: var(--sunken);
  border-color: var(--muted);
}
.btn-ghost {
  color: var(--ink-2);
  background: transparent;
}
.btn-ghost:hover {
  background: var(--sunken);
  color: var(--ink);
}
.btn-sm {
  min-height: 2.25rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 7px;
}
.btn-lg {
  min-height: 3.25rem;
  padding: 0.8rem 1.4rem;
  font-size: 1rem;
}
.btn-icon {
  min-height: 2.5rem;
  width: 2.5rem;
  padding: 0;
}

/* ───────────── Links */
.link {
  color: var(--ledger);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--ledger) 35%, transparent);
}
.link:hover {
  text-decoration-color: currentColor;
}
.link-quiet {
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
}
.link-quiet:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

/* ───────────── Surfaces */
.card {
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-xs);
}
.card-hover {
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    background-color 160ms ease;
}
.card-hover:hover {
  border-color: var(--rule-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-hover:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-2);
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}
a.chip:hover,
button.chip:hover {
  border-color: var(--ledger);
  color: var(--ledger);
  background: var(--ledger-tint);
}
a.chip:active,
button.chip:active {
  background: var(--ledger-soft);
}
.chip-active {
  border-color: var(--ledger);
  background: var(--ledger-soft);
  color: var(--ledger);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ledger);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  font-family: var(--font-sans);
}
}

/* ───────────── Admin: dense data tables, compact controls */
@layer components {
  .field {
    min-height: 2.375rem;
    font-size: 0.875rem;
    padding: 0.45rem 0.7rem;
  }
  select.field {
    padding-right: 2rem;
    background-position: right 0.55rem center;
  }
  .btn {
    min-height: 2.375rem;
    font-size: 0.875rem;
    padding: 0.45rem 0.95rem;
  }
  .btn-sm {
    min-height: 2rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
  }
  .btn-xs {
    min-height: 1.75rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    border-radius: 6px;
  }
  .btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: var(--shadow-xs);
  }
  .btn-danger:hover {
    background: color-mix(in srgb, var(--danger) 88%, black);
  }
  .btn-danger-quiet {
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
    color: var(--danger);
    background: var(--surface);
  }
  .btn-danger-quiet:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
  }
  .tbl {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
  }
  .tbl th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--paper);
    padding: 9px 14px;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
  }
  .tbl td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
  }
  .tbl tr:last-child td {
    border-bottom: 0;
  }
  .tbl tbody tr {
    transition: background-color 120ms ease;
  }
  .tbl tbody tr:hover {
    background: var(--ledger-tint);
  }
  .tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 7px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-2);
    text-transform: capitalize;
    transition:
      background-color 120ms ease,
      color 120ms ease;
  }
  .tab:hover {
    background: var(--surface);
    color: var(--ink);
  }
  .tab[aria-current='page'] {
    background: var(--surface);
    color: var(--ledger);
    box-shadow: var(--shadow-sm);
  }
}

/* Subtle ledger-ruled backdrop for hero areas */
.hero-backdrop {
  background:
    radial-gradient(60rem 30rem at 85% -10%, color-mix(in srgb, var(--ledger) 10%, transparent), transparent 70%),
    radial-gradient(40rem 24rem at -10% 110%, color-mix(in srgb, var(--brass) 9%, transparent), transparent 70%),
    var(--surface);
}
.hero-grid {
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--rule) 55%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--rule) 55%, transparent) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 70% 30%, black 10%, transparent 70%);
}

/* Disclosure chevrons rotate when their <details> opens */
details[open] > summary .disclosure-chevron {
  transform: rotate(180deg);
}
.disclosure-chevron {
  transition: transform 180ms ease;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* One orchestrated moment: the hero ledger fills in on first paint */
@keyframes ledger-fill {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}
.ledger-animate > span {
  transform-origin: left center;
  animation: ledger-fill 700ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.pop-in {
  animation: pop-in 140ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.fade-up {
  animation: fade-up 260ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

/* Keep action glyphs aligned with labels at every button size. */
.btn > svg { flex-shrink: 0; width: 1rem; height: 1rem; }
.btn-xs { gap: 0.375rem; }
.btn-xs > svg { width: 0.875rem; height: 0.875rem; }

/* Decorative field icons retain the label text and input associations. */
.field-label:has(> svg) { display: flex; align-items: center; gap: 0.375rem; }
.field-label > svg { width: 0.875rem; height: 0.875rem; flex-shrink: 0; color: var(--muted); }
