/* Exclusif public site. Palette is the operator dashboard's shipped palette
   (apps/dashboard/src/styles.scss); keep the two in step. */
:root {
  --font-sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;

  --bg-void: #07080b;
  --bg-base: #0c0e13;
  --bg-surface: #111318;
  --bg-elevated: #16181f;
  --bg-input: #0e1015;

  --border-dim: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.14);

  --text-primary: #e8eaed;
  --text-secondary: #9a9ea8;
  --text-muted: #6b6f78;

  --purple: #8b5cf6;
  --purple-soft: #a78bfa;
  --purple-dim: rgba(139, 92, 246, 0.12);
  --cyan: #22d3ee;
  --green: #10b981;
  --red: #f87171;

  --wrap: 1120px;
  --measure: 38rem;
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-void);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(2.5rem, 5.4vw, 4.1rem);
  letter-spacing: -0.04em;
  line-height: 1.02;
}

h2 {
  font-size: clamp(1.6rem, 2.8vw, 2.15rem);
}

h3 {
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

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

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: 6px;
  z-index: 10;
}

.skip:focus {
  top: 1rem;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Header / footer ── */

.site-header {
  border-bottom: 1px solid var(--border-dim);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
}

.wordmark {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.95rem;
}

.site-nav a:not(.button) {
  color: var(--text-secondary);
  text-decoration: none;
}

.site-nav a:not(.button):hover {
  color: var(--text-primary);
}

.site-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--border-dim);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding-top: 2rem;
  padding-bottom: 2.5rem;
}

.footer-made a,
.footer-nav a {
  color: var(--text-secondary);
}

.footer-nav {
  display: flex;
  gap: 1.25rem;
}

/* ── Buttons and links ── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0 1.3rem;
  border-radius: 10px;
  border: 1px solid var(--purple);
  background: var(--purple);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: #7c4ff0;
}

.button-small {
  min-height: 2.25rem;
  padding: 0 0.95rem;
  font-size: 0.92rem;
  border-radius: 8px;
}

.button-quiet {
  background: transparent;
  border-color: var(--border-bright);
  color: var(--text-primary);
}

.button-quiet:hover {
  background: var(--bg-elevated);
}

.button[disabled] {
  opacity: 0.55;
  cursor: progress;
}

.text-link {
  color: var(--purple-soft);
  font-weight: 600;
  text-underline-offset: 3px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ── Home: hero ── */

.hero {
  padding: clamp(3rem, 8vw, 6.5rem) 0 clamp(3rem, 7vw, 5.5rem);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(2.5rem, 5vw, 4.5rem);
  align-items: center;
}

.hero-copy h1 {
  max-width: 13ch;
}

.lede {
  margin-top: 1.5rem;
  max-width: 34rem;
  font-size: 1.2rem;
  color: var(--text-secondary);
}

.hero-copy .actions {
  margin-top: 2rem;
}

.fineprint {
  margin-top: 1.1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* The ledger: the page's one moving part. */

.ledger {
  margin: 0;
  padding: 1.4rem 1.4rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.ledger-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.ledger-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
}

.ledger-total {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.ledger-total [data-remaining] {
  color: var(--text-primary);
}

.ledger-bar {
  height: 6px;
  margin: 0.9rem 0 1rem;
  border-radius: 99px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.ledger-bar span {
  display: block;
  height: 100%;
  background: var(--purple);
  border-radius: inherit;
  transition: width 260ms ease-out;
}

.ledger-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  height: calc(8 * 2.15rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.ledger-rows li {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  align-items: center;
  min-height: 2.15rem;
  border-top: 1px solid var(--border-dim);
  font-variant-numeric: tabular-nums;
}

.ledger-rows .n {
  color: var(--text-muted);
}

.ledger-rows .who {
  color: var(--text-secondary);
}

.ledger-rows .grant {
  color: var(--cyan);
}

.ledger-rows .grant-access {
  color: var(--text-muted);
}

.ledger-rows li.is-new {
  animation: ledger-in 420ms ease-out;
}

@keyframes ledger-in {
  from {
    background: var(--purple-dim);
  }
  to {
    background: transparent;
  }
}

.ledger-note {
  margin-top: 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--text-secondary);
  min-height: 2.8em;
}

/* ── Home: sections ── */

.section {
  padding: clamp(3rem, 6vw, 4.75rem) 0;
  border-top: 1px solid var(--border-dim);
}

.section h2 + * {
  margin-top: 1.25rem;
}

.prose-block {
  max-width: calc(var(--measure) + 3rem);
}

.prose-block p + p,
.prose-block .math + p {
  margin-top: 1.1rem;
}

.prose-block p {
  color: var(--text-secondary);
}

.math {
  margin: 1.75rem 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.math p {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.55rem 0;
  color: var(--text-secondary);
  border-bottom: 1px dashed var(--border);
}

.prose-block .math p + p {
  margin-top: 0;
}

.math .math-total {
  color: var(--text-primary);
  border-bottom: 0;
}

.math .math-total span:last-child {
  color: var(--cyan);
}

.section-lede {
  max-width: 30rem;
  color: var(--text-secondary);
}

.section-lede + p {
  margin-top: 1.25rem;
}

.steps {
  counter-reset: step;
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.5rem;
}

.steps li {
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: block;
  margin-bottom: 0.9rem;
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--purple-soft);
}

.steps p,
.uses p,
.controls dd {
  margin-top: 0.5rem;
  color: var(--text-secondary);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.controls {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem 2.25rem;
}

.controls dt {
  font-weight: 600;
}

.controls dd {
  margin-left: 0;
}

.uses {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.uses > div {
  padding: 0 2rem;
  border-left: 1px solid var(--border);
}

.uses > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.code {
  margin: 0;
  padding: 1.4rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.code .c {
  color: var(--text-muted);
}

.code .k {
  color: var(--purple-soft);
}

.code .s {
  color: var(--cyan);
}

.code .n {
  color: #f0abfc;
}

.closing {
  text-align: center;
}

.closing p {
  color: var(--text-secondary);
}

.closing .actions {
  margin-top: 1.75rem;
  justify-content: center;
}

.section-end {
  padding-bottom: clamp(4rem, 8vw, 6rem);
}

/* ── Docs and legal ── */

.doc {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 3.5rem;
  padding-top: 3rem;
  padding-bottom: 4rem;
}

.doc-nav {
  position: sticky;
  top: 1.5rem;
  align-self: start;
  font-size: 0.93rem;
}

.doc-nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-nav li + li {
  margin-top: 0.45rem;
}

.doc-nav a {
  color: var(--text-secondary);
  text-decoration: none;
}

.doc-nav a:hover {
  color: var(--text-primary);
}

.prose {
  max-width: 44rem;
}

.prose h1 {
  font-size: clamp(2.1rem, 4vw, 2.8rem);
}

.prose h2 {
  margin-top: 3rem;
  font-size: 1.6rem;
  scroll-margin-top: 1.5rem;
}

.prose h3 {
  margin-top: 2rem;
  scroll-margin-top: 1.5rem;
}

.prose p,
.prose ul,
.prose ol,
.prose table,
.prose pre {
  margin-top: 1rem;
}

.prose p,
.prose li {
  color: var(--text-secondary);
}

.prose strong {
  color: var(--text-primary);
}

.prose ul,
.prose ol {
  padding-left: 1.3rem;
}

.prose li + li {
  margin-top: 0.4rem;
}

.prose a {
  color: var(--purple-soft);
  text-underline-offset: 3px;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 0.1em 0.35em;
  background: var(--bg-elevated);
  border-radius: 5px;
  color: var(--text-primary);
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.75rem 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.prose th {
  color: var(--text-primary);
  font-weight: 600;
}

.prose td {
  color: var(--text-secondary);
}

.prose .updated {
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.93rem;
}

.legal {
  padding-top: 3rem;
  padding-bottom: 4rem;
}

.note {
  padding: 1rem 1.2rem;
  border-left: 3px solid var(--purple);
  background: var(--bg-surface);
  border-radius: 0 10px 10px 0;
}

/* ── Hosted join page ── */

.page-join .site-header,
.page-join .site-footer {
  display: none;
}

.join {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 3rem 1.5rem;
}

.join-card {
  width: 100%;
  max-width: 30rem;
}

.join-card h1 {
  font-size: clamp(2rem, 5vw, 2.6rem);
}

.join-card .lede {
  margin-top: 1rem;
  font-size: 1.05rem;
}

.join-status {
  margin-top: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.join-status strong {
  color: var(--cyan);
  font-weight: 500;
}

.join-form {
  margin-top: 1.75rem;
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field label {
  font-weight: 600;
  font-size: 0.95rem;
}

.field input {
  width: 100%;
  min-height: 2.9rem;
  padding: 0 0.9rem;
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-primary);
  font: inherit;
}

.field input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}

.form-error {
  color: var(--red);
  font-size: 0.95rem;
}

.join-done h2 {
  font-size: 1.5rem;
}

.join-done p {
  margin-top: 0.75rem;
  color: var(--text-secondary);
}

.join-powered {
  margin-top: 2.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.join-powered a {
  color: var(--text-secondary);
}

[hidden] {
  display: none !important;
}

/* ── Responsive ── */

@media (max-width: 900px) {
  .hero-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .steps,
  .uses {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .uses > div,
  .uses > div:first-child {
    padding: 0;
    border-left: 0;
  }

  .doc {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .doc-nav {
    position: static;
  }
}

@media (max-width: 560px) {
  .site-nav {
    gap: 1rem;
  }

  .site-nav a[href='/docs/'] {
    display: none;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .math p {
    flex-direction: column;
    gap: 0.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ledger-bar span {
    transition: none;
  }

  .ledger-rows li.is-new {
    animation: none;
  }
}
