/* ==========================================================================
   veil.protocol — design system
   One rule governs the palette: the spectrum appears where two things meet,
   and nowhere else. Amber means capital is at stake. Mono means verifiable.
   ========================================================================== */

:root {
  /* ground */
  --void: #05060A;
  --surface: #0C0E16;
  --raised: #131727;
  --line: #1E2333;
  --line-bright: #2C3348;

  /* text */
  --bone: #E9E7E2;
  --dim: #8A90A6;
  --faint: #5A6078;

  /* interference — seams, intersections, active states only */
  --veil-1: #2DE2C5;
  --veil-2: #6B5CFF;
  --veil-3: #A855F7;
  --seam: linear-gradient(90deg, var(--veil-1), var(--veil-2) 50%, var(--veil-3));

  /* value — money, never decoration */
  --amber: #FFB347;

  /* state */
  --ok: #2DE2C5;
  --warn: #FFB347;
  --bad: #FF6B6B;

  /* Display is a high-contrast didone: this is an instrument, not a dashboard.
     Text is Public Sans, the face of a government design system — official
     documents, not startup landing pages. Mono is reserved strictly for values
     that exist on-chain. */
  --display: "Bodoni Moda", "Didot", Georgia, serif;
  --body: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(20px, 5vw, 64px);
  --measure: 62ch;
  --radius: 2px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--void);
  color: var(--bone);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1180px; margin: 0 auto; padding-inline: var(--gutter); }
.wrap--narrow { max-width: 880px; }

/* ------------------------------------------------------------------ type */

h1, h2, .display {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.02;
  text-wrap: balance;
  margin: 0;
}
h1 { font-size: clamp(2.5rem, 7.4vw, 5.6rem); }
h2 { font-size: clamp(1.75rem, 4.2vw, 3rem); }
h3 {
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0;
  line-height: 1.35;
  margin: 0;
}

/* Clause marks. Set as marginalia in a legal instrument: roman numeral,
   italic didone, no tracking, no uppercase. The tracked-out monospace label
   is banned from this system. */
.eyebrow {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--faint);
  margin: 0;
}
p { margin: 0; max-width: var(--measure); }
.lede { font-size: clamp(1.02rem, 2vw, 1.3rem); color: var(--dim); }
.note { font-family: var(--body); font-size: 0.84rem; color: var(--faint); line-height: 1.6; }
.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.val { color: var(--amber); }
strong { color: var(--bone); font-weight: 500; }
a { color: var(--bone); }

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

.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 13px var(--gutter);
  background: color-mix(in srgb, var(--void) 84%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
/* The engraved band along the foot of the header. It stands in for the bottom
   border rather than sitting above one, so the header gains no height. */
.bar { position: sticky; }
.strip {
  position: absolute; left: 0; right: 0; bottom: -1px;
  width: 100%; height: 13px; display: block; pointer-events: none;
}
@media (max-width: 760px) { .strip { height: 9px; } }

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--bone); }
.brand .mark { width: 30px; height: 30px; display: block; flex: none; }
/* The mark is drawn, not placed. It leans into a hover and settles back. */
.brand canvas.mark { border-radius: 50%; }
.brand .name {
  font-family: var(--display); font-weight: 500; text-transform: none;
  letter-spacing: -0.01em; font-size: 1.12rem;
}
.brand .name span { color: var(--faint); font-weight: 500; }

.nav { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.nav a {
  font-family: var(--body); font-size: 0.86rem; letter-spacing: 0;
  color: var(--dim); text-decoration: none; padding: 4px 0;
  border-bottom: 1px solid transparent;
}
.nav a:hover, .nav a:focus-visible { color: var(--bone); border-bottom-color: var(--veil-1); }
.nav a[aria-current="page"] { color: var(--bone); border-bottom-color: var(--veil-1); }

/* The one action that always survives. Styled as a control, not a link. */
.nav__cta {
  border: 1px solid var(--line-bright);
  border-radius: 2px;
  padding: 7px 15px !important;
  color: var(--bone) !important;
}
.nav__cta:hover, .nav__cta:focus-visible { border-color: var(--veil-2) !important; background: var(--raised); }

/* A sticky header must never eat half a phone screen. Below this width the
   secondary links drop and only the brand and the single action remain. */
@media (max-width: 760px) {
  .bar { padding: 10px var(--gutter); }
  .nav { gap: 0; }
  .nav a:not(.nav__cta) { display: none; }
  .brand .name { font-size: 0.84rem; }
}

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--veil-1);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  font-family: var(--body); font-size: 0.88rem; font-weight: 500; letter-spacing: 0;
  padding: 12px 22px; border-radius: 2px;
  border: 1px solid var(--line-bright); color: var(--bone); background: var(--surface);
  text-decoration: none; display: inline-flex; align-items: center; gap: 9px;
  cursor: pointer; transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}
.btn:hover:not(:disabled), .btn:focus-visible { border-color: var(--veil-2); background: var(--raised); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary { background: var(--bone); color: var(--void); border-color: var(--bone); font-weight: 500; }
.btn--primary:hover:not(:disabled), .btn--primary:focus-visible { background: #fff; border-color: #fff; color: var(--void); }
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn--danger:hover:not(:disabled) { border-color: var(--bad); background: var(--raised); }
.btn--sm { padding: 8px 14px; font-size: 0.75rem; }

/* --------------------------------------------------------------- sections */

.section { padding-block: clamp(44px, 7vw, 88px); border-top: 1px solid var(--line); }
.sec-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 38px; }

.grid-3 { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
@media (min-width: 760px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.cell { background: var(--void); padding: 26px 22px; display: flex; flex-direction: column; gap: 11px; }
.cell .step { font-family: var(--display); font-style: italic; font-size: 0.95rem; color: var(--veil-1); }
.cell p { color: var(--dim); font-size: 0.93rem; }

/* ------------------------------------------------------------- pact card */

.pact {
  background: var(--surface); border: 1px solid var(--line-bright);
  border-radius: var(--radius); overflow: hidden;
}
.pact__seam { height: 2px; background: var(--seam); }
.pact__body { padding: 20px; display: flex; flex-direction: column; gap: 18px; }

.pair { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.pair .tick { font-family: var(--display); font-weight: 500; font-size: 1.5rem; letter-spacing: -0.01em; }
.pair .x { color: var(--faint); font-family: var(--mono); }

.status {
  font-family: var(--body); font-size: 0.72rem; font-weight: 500; letter-spacing: 0;
  text-transform: none; padding: 3px 9px; border-radius: 2px;
  border: 1px solid currentColor; margin-left: auto; white-space: nowrap;
}
.status--live, .status--active { color: var(--ok); }
.status--proposed { color: var(--warn); }
.status--broken { color: var(--bad); }
.status--cancelled, .status--settled { color: var(--faint); }

.rows { display: flex; flex-direction: column; margin: 0; }
.row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.87rem;
}
.row:last-child { border-bottom: 0; }
.row dt { color: var(--dim); font-family: var(--body); font-size: 0.85rem; letter-spacing: 0; }
.row dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

.meter { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--veil-1), var(--veil-2)); }

/* ------------------------------------------------------------------ forms */

.field-row { display: flex; flex-direction: column; gap: 7px; }
.field-row label {
  font-family: var(--body); font-size: 0.85rem; font-weight: 500;
  letter-spacing: 0; text-transform: none; color: var(--dim);
}
.field-row .hint { font-family: var(--mono); font-size: 0.7rem; color: var(--faint); }

input[type="text"], input[type="number"], select, textarea {
  width: 100%; padding: 11px 13px;
  background: var(--void); color: var(--bone);
  border: 1px solid var(--line-bright); border-radius: 4px;
  font-family: var(--mono); font-size: 0.85rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--veil-2); outline: none; }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; font-family: var(--body); }
select { appearance: none; cursor: pointer; }

.form-grid { display: grid; gap: 18px; }
@media (min-width: 680px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------------ panel */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 18px;
}
.panel--seam { border-top: 2px solid transparent; border-image: var(--seam) 1; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 60; max-width: min(560px, calc(100vw - 32px));
  background: var(--raised); border: 1px solid var(--line-bright);
  border-radius: var(--radius); padding: 13px 17px;
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.5;
  display: none; word-break: break-word;
}
.toast[data-open="true"] { display: block; }
.toast[data-kind="ok"] { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.toast[data-kind="bad"] { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); color: var(--bad); }

.empty {
  border: 1px dashed var(--line-bright); border-radius: var(--radius);
  padding: 34px 22px; text-align: center; color: var(--faint);
  font-family: var(--mono); font-size: 0.82rem;
}

.foot { border-top: 1px solid var(--line); padding-block: 34px 52px; }
.foot-grid { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; align-items: baseline; }

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


/* ------------------------------------------------------------ the board */

.zone { margin-bottom: 46px; }
.zone__head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding-bottom: 14px; border-bottom: 1px solid var(--line-bright); margin-bottom: 20px;
}
.zone__name { font-family: var(--display); font-size: clamp(1.3rem, 3vw, 1.8rem); letter-spacing: -0.01em; }
.zone__count {
  font-family: var(--mono); font-size: 0.78rem; color: var(--void);
  background: var(--dim); border-radius: 2px; padding: 2px 8px; line-height: 1.5;
}
.zone__what { font-size: 0.92rem; color: var(--faint); flex: 1 1 260px; min-width: 0; }
.zone[data-tone="open"] .zone__count { background: var(--warn); }
.zone[data-tone="term"] .zone__count { background: var(--veil-1); }
.zone[data-tone="unwinding"] .zone__count { background: var(--veil-2); color: var(--bone); }
.zone[data-tone="closed"] .zone__count { background: var(--faint); }

.board { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; text-align: left;
  display: flex; flex-direction: column; cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
  font: inherit; color: inherit; padding: 0;
}
.card:hover, .card:focus-visible { border-color: var(--line-bright); background: var(--raised); }
.card__seal { position: relative; aspect-ratio: 1.45; background: var(--void); border-bottom: 1px solid var(--line); }
.card__seal canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.card__badge {
  position: absolute; top: 9px; left: 9px;
  font-size: 0.7rem; font-weight: 500; padding: 3px 8px;
  border-radius: 2px; border: 1px solid currentColor;
  background: color-mix(in srgb, var(--void) 78%, transparent);
}
.card__id {
  position: absolute; bottom: 8px; right: 10px;
  font-family: var(--mono); font-size: 0.72rem; color: var(--faint);
  background: color-mix(in srgb, var(--void) 70%, transparent); padding: 1px 5px; border-radius: 2px;
}
.card__body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 9px; }
.card__pair { font-family: var(--display); font-size: 1.02rem; letter-spacing: -0.01em; }
.card__pair span { color: var(--faint); }
.card__meta { display: flex; justify-content: space-between; gap: 10px; font-size: 0.8rem; color: var(--dim); }
.card__meta .t { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.card__meter { height: 2px; background: var(--line); overflow: hidden; }
.card__meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--veil-1), var(--veil-2)); }
