/* TraraLink shared tokens and components. No framework, no external assets. */

:root {
  color-scheme: dark;

  /* Approved brand colours */
  --ink: #1C1813;
  --paper: #F3EAD9;
  --signal: #FF7A3D;

  /* Derived from the brand colours */
  --ink-sunk: #15120E;
  --ink-raised: #241F19;
  --line: #3A3229;
  --line-strong: #5C4F3F;
  --paper-dim: #B9AD98;
  --signal-deep: #C9541F;
  /* Used only for simulated data, so it never reads as the brand */
  --sim: #8FD3FF;

  /* Bricolage Grotesque and Inter are used when installed locally (both SIL OFL 1.1).
     Nothing is fetched; see assets/fonts/README.md for optional bundling. */
  --font-brand: "Bricolage Grotesque", "Bahnschrift", "Segoe UI Variable Display", "Avenir Next", system-ui, sans-serif;
  --font-ui: "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;

  /* Classic typographic scale */
  --t-12: 0.75rem;
  --t-14: 0.875rem;
  --t-16: 1rem;
  --t-18: 1.125rem;
  --t-21: 1.3125rem;
  --t-24: 1.5rem;
  --t-36: 2.25rem;
  --t-48: 3rem;
  --t-60: 3.75rem;
  --t-72: 4.5rem;

  --fold: 8px; /* the top-left chamfer that echoes the mark */
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --measure: 38rem;
}

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

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: var(--t-16);
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01";
}

h1,
h2,
h3 {
  font-family: var(--font-brand);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration-color: var(--signal);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--signal);
}

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

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
}

.skip:focus {
  top: 0.5rem;
}

.num {
  font-variant-numeric: tabular-nums lining-nums;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.4em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  font: inherit;
  font-size: 0.85em;
  text-align: center;
  color: var(--paper-dim);
}

/* Buttons: 44 px minimum hit target everywhere */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--paper);
  color: var(--paper);
}

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

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

.btn--sim {
  border-color: var(--sim);
  color: var(--sim);
}

.btn--sim:hover {
  background: var(--sim);
  color: var(--ink);
  border-color: var(--sim);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* State chips. Shape and text carry the meaning; colour only reinforces it. */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem 0.15rem 0.7rem;
  font-size: var(--t-14);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  clip-path: polygon(6px 0, 100% 0, 100% 100%, 0 100%, 0 6px);
  background: var(--line);
  color: var(--paper);
}

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

.chip--paper {
  background: var(--paper);
  color: var(--ink);
}

.chip--hatch {
  background: repeating-linear-gradient(-45deg, var(--line-strong) 0 3px, var(--line) 3px 7px);
  color: var(--paper);
}

.chip--muted {
  background: transparent;
  color: var(--paper-dim);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  clip-path: none;
}

.chip--sim {
  background: var(--sim);
  color: var(--ink);
}

/* Corner badge: a 22 px mark inside a 44 px hit target. States are told apart by
   fill versus outline, not colour alone, and the accessible name carries the state. */

.badge {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.badge__mark {
  display: block;
  width: 22px;
  height: 22px;
}

.badge__mark path {
  fill: var(--badge-fill, none);
  stroke: var(--badge-stroke, currentColor);
  stroke-width: 1.4px;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
}

.badge:hover,
.badge:focus-visible {
  background: var(--ink-raised);
}

.badge[data-connection="connecting"] {
  --badge-fill: none;
  --badge-stroke: var(--paper-dim);
}

.badge[data-connection="connected"] {
  --badge-fill: var(--signal);
  --badge-stroke: var(--signal);
}

.badge[data-connection="stale"] {
  --badge-fill: none;
  --badge-stroke: var(--signal);
}

.badge[data-connection="disconnected"],
.badge[data-connection="incompatible"] {
  --badge-fill: none;
  --badge-stroke: var(--paper-dim);
}

.badge[data-source="demo"] {
  --badge-fill: var(--sim);
  --badge-stroke: var(--sim);
}

/* A tick in the badge corner marks "not connected" for anyone who cannot rely on fill. */
.badge[data-connection="disconnected"]::after,
.badge[data-connection="incompatible"]::after {
  content: "";
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 6px;
  height: 6px;
  background: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--paper-dim);
  transform: rotate(45deg);
}

.badge__tip {
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  padding: 0.25rem 0.6rem;
  background: var(--paper);
  color: var(--ink);
  font-size: var(--t-14);
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}

.badge:hover .badge__tip,
.badge:focus-visible .badge__tip {
  opacity: 1;
}

@media (hover: none) {
  .badge__tip {
    display: none;
  }
}

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