/* ============================================================
   TYPE BUREAU — shared design system
   Ground: bone paper / graphite ink. Signal: cobalt. Data: ochre.
   No green anywhere (explicit brand constraint).
   ============================================================ */

:root {
  color-scheme: light dark;

  /* --- surfaces (neutrals tinted toward the cobalt signal) --- */
  --bg: #eeece6;
  --surface: #f9f8f4;
  --surface-2: #e3e1d8;
  --surface-3: #d8d5ca;
  --fg: #14141b;
  --fg-2: #4a4a55;
  --fg-3: #7a7883;
  --line: #d3d0c5;
  --line-strong: #b4b0a3;

  /* --- signal --- */
  --signal: #2233e8;
  --signal-ink: #ffffff;
  --signal-soft: #dfe1ff;
  --ochre: #9c6712;
  --ochre-soft: #f0e3cb;

  /* --- chrome (always dark, in both themes: the rail is the console) --- */
  --chrome: #14151c;
  --chrome-2: #1e202a;
  --chrome-fg: #eae8e1;
  --chrome-fg-2: #918f9c;
  --chrome-line: #2b2d38;

  /* --- type --- */
  --ui: 'Switzer', ui-sans-serif, system-ui, sans-serif;
  --display: 'Cabinet Grotesk', 'Switzer', ui-sans-serif, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', monospace;

  --step--1: clamp(0.72rem, 0.7rem + 0.1vw, 0.79rem);
  --step-0: clamp(0.92rem, 0.89rem + 0.14vw, 1rem);
  --step-1: clamp(1.18rem, 1.1rem + 0.4vw, 1.42rem);
  --step-2: clamp(1.5rem, 1.32rem + 0.9vw, 2.15rem);
  --step-3: clamp(2rem, 1.6rem + 2vw, 3.4rem);
  --step-4: clamp(2.9rem, 1.9rem + 5vw, 6.5rem);

  /* --- space (4pt) --- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  --rail: 60px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0e13;
    --surface: #15161d;
    --surface-2: #1d1f28;
    --surface-3: #262835;
    --fg: #ecebe4;
    --fg-2: #adacb7;
    --fg-3: #7c7b88;
    --line: #262832;
    --line-strong: #3b3e4c;
    --signal: #8492ff;
    --signal-ink: #0d0e13;
    --signal-soft: #1c2144;
    --ochre: #d9a64f;
    --ochre-soft: #33290f;
    --chrome: #08090d;
    --chrome-2: #12131a;
    --chrome-fg: #ecebe4;
    --chrome-fg-2: #83828f;
    --chrome-line: #21232d;
  }
}

:root[data-theme='dark'] {
  --bg: #0d0e13;
  --surface: #15161d;
  --surface-2: #1d1f28;
  --surface-3: #262835;
  --fg: #ecebe4;
  --fg-2: #adacb7;
  --fg-3: #7c7b88;
  --line: #262832;
  --line-strong: #3b3e4c;
  --signal: #8492ff;
  --signal-ink: #0d0e13;
  --signal-soft: #1c2144;
  --ochre: #d9a64f;
  --ochre-soft: #33290f;
  --chrome: #08090d;
  --chrome-2: #12131a;
  --chrome-fg: #ecebe4;
  --chrome-fg-2: #83828f;
  --chrome-line: #21232d;
}

:root[data-theme='light'] {
  --bg: #eeece6;
  --surface: #f9f8f4;
  --surface-2: #e3e1d8;
  --surface-3: #d8d5ca;
  --fg: #14141b;
  --fg-2: #4a4a55;
  --fg-3: #7a7883;
  --line: #d3d0c5;
  --line-strong: #b4b0a3;
  --signal: #2233e8;
  --signal-ink: #ffffff;
  --signal-soft: #dfe1ff;
  --ochre: #9c6712;
  --ochre-soft: #f0e3cb;
  --chrome: #14151c;
  --chrome-2: #1e202a;
  --chrome-fg: #eae8e1;
  --chrome-fg-2: #918f9c;
  --chrome-line: #2b2d38;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ui);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  font-synthesis-weight: none;
}

a {
  color: inherit;
}

::selection {
  background: var(--signal);
  color: var(--signal-ink);
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
  border-radius: 2px;
}

h1,
h2,
h3,
h4 {
  font-family: var(--display);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* ---------- shared atoms ---------- */

.label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  font-weight: 500;
}

.rule {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

/* ---------- top chrome ---------- */

.bureau-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  height: 52px;
  padding: 0 var(--s-4) 0 var(--s-3);
  background: var(--chrome);
  color: var(--chrome-fg);
  border-bottom: 1px solid var(--chrome-line);
}

.bureau-bar a {
  text-decoration: none;
}

.bb-mark {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-right: var(--s-4);
  border-right: 1px solid var(--chrome-line);
  height: 100%;
}

.bb-mark svg {
  display: block;
}

.bb-mark b {
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.bb-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}

.bb-nav::-webkit-scrollbar {
  display: none;
}

.bb-nav a {
  padding: 6px 10px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 500;
  color: var(--chrome-fg-2);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.bb-nav a:hover {
  color: var(--chrome-fg);
  background: var(--chrome-2);
}

.bb-nav a[aria-current='page'] {
  color: var(--chrome-fg);
  background: var(--chrome-2);
}

.bb-right {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* font-health chip — must always tell the truth */
.fontchip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--chrome-line);
  border-radius: 999px;
  background: var(--chrome-2);
  color: var(--chrome-fg-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.fontchip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chrome-fg-2);
  flex: none;
}

.fontchip[data-state='loading'] .dot {
  background: var(--ochre);
  animation: pulse 1.1s var(--ease) infinite;
}

.fontchip[data-state='ok'] .dot {
  background: #4d7cff;
}

.fontchip[data-state='ok'] {
  color: var(--chrome-fg);
}

.fontchip[data-state='partial'] .dot,
.fontchip[data-state='fail'] .dot {
  background: #e0763c;
}

.fontchip[data-state='partial'],
.fontchip[data-state='fail'] {
  color: #f0a97f;
  border-color: #55341f;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.iconbtn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--chrome-line);
  background: var(--chrome-2);
  color: var(--chrome-fg-2);
  border-radius: 999px;
  padding: 0;
}

.iconbtn:hover {
  color: var(--chrome-fg);
  border-color: var(--line-strong);
}

/* font health detail sheet */
.health {
  position: fixed;
  inset: 52px 0 auto auto;
  z-index: 70;
  width: min(420px, calc(100vw - 16px));
  margin: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.4);
  padding: var(--s-4);
  display: none;
}

.health[data-open='true'] {
  display: block;
}

.health h4 {
  font-size: 13px;
  font-family: var(--ui);
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 2px;
}

.health-list {
  max-height: 40vh;
  overflow: auto;
  margin: var(--s-3) 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 11px;
  display: grid;
  gap: 3px;
}

.health-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
  color: var(--fg-2);
}

.health-list li b {
  font-weight: 500;
  color: var(--fg);
}

.health-list li span[data-s='live'] {
  color: var(--signal);
}

.health-list li span[data-s='fallback'] {
  color: #c0632c;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s var(--ease);
}

.btn:hover {
  background: var(--surface);
  border-color: var(--fg-3);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--signal-ink);
}

.btn--primary:hover {
  background: color-mix(in oklab, var(--signal) 88%, var(--fg));
  border-color: transparent;
}

/* range inputs, used by every tool */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  margin: 0;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line-strong);
}

input[type='range']::-moz-range-track {
  height: 2px;
  background: var(--line-strong);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--signal);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--signal);
}

input[type='range']::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--signal);
  border: 2px solid var(--surface);
}

.ctl {
  display: grid;
  gap: 5px;
}

.ctl > .ctl-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-3);
}

.ctl-head b {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  font-weight: 500;
}

.ctl-head i {
  font-family: var(--mono);
  font-style: normal;
  font-size: 11px;
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  background: var(--surface);
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--fg-3);
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  border-right: 1px solid var(--line);
}

.seg button:last-child {
  border-right: 0;
}

.seg button[aria-pressed='true'] {
  background: var(--fg);
  color: var(--bg);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-2);
  cursor: pointer;
  user-select: none;
}

.switch input {
  appearance: none;
  width: 30px;
  height: 17px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background 0.18s;
  margin: 0;
  flex: none;
}

.switch input::after {
  content: '';
  position: absolute;
  inset: 2px auto 2px 2px;
  width: 13px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.18s var(--ease);
}

.switch input:checked {
  background: var(--signal);
}

.switch input:checked::after {
  transform: translateX(13px);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
