/* karat67 — assay report for indexed Solana accounts.
   The page is the report. The readout panel is the instrument inside it. */

:root {
  --paper: #e9ebe8;
  --leaf: #f4f5f3;
  --ink: #15181a;
  --muted: #5a6468;
  --rule: #c9cec9;
  --graphite: #171a1c;

  --brass: #7a5f1e;
  --brass-bright: #c9a227;
  --oxide: #a3301f;
  --oxide-bright: #e8705c;
  --slate: #5f6e75;
  --slate-bright: #94a7b0;

  --sans: "Archivo", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --gutter: clamp(1.25rem, 5vw, 4rem);
  --measure: 68rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--brass);
}

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

.shell {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.85rem var(--gutter);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
}

.wordmark {
  font-weight: 800;
  font-stretch: 125%;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.topbar-nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.topbar-nav a {
  text-decoration: none;
}

.topbar-nav a:hover {
  color: var(--ink);
}

/* ------------------------------------------------------------------- hero */

.hero {
  padding: clamp(3rem, 9vw, 6rem) 0 clamp(2rem, 5vw, 3rem);
}

.hero-title {
  margin: 0;
  font-weight: 800;
  font-stretch: 125%;
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  max-width: 16ch;
}

.hero-lede {
  margin: 1.75rem 0 0;
  max-width: 54ch;
  font-size: clamp(1.05rem, 2vw, 1.2rem);
  line-height: 1.5;
  color: var(--muted);
}

.hero-lede strong {
  color: var(--ink);
  font-weight: 600;
}

/* ------------------------------------------------------------- instrument */

.instrument {
  padding-bottom: clamp(3rem, 7vw, 5rem);
}

.instrument-grid {
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

@media (min-width: 60rem) {
  .instrument-grid {
    grid-template-columns: 22rem 1fr;
  }
}

.panel {
  background: var(--leaf);
  padding: 1.5rem;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.panel-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ------------------------------------------------------------- case picker */

.cases {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--rule);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.case {
  background: var(--leaf);
}

.case-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.case-label {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.1rem 0.7rem;
  padding: 0.85rem 0.9rem;
  cursor: pointer;
  transition: background 120ms ease;
}

.case-label:hover {
  background: #eef0ed;
}

.case-input:focus-visible + .case-label {
  outline: 2px solid var(--brass);
  outline-offset: -2px;
}

.case-input:checked + .case-label {
  background: var(--paper);
  box-shadow: inset 3px 0 0 var(--brass);
}

/* Continues the selected live case: same fill and rule, aligned to its text. */
.live-picker {
  display: grid;
  gap: 0.9rem;
  padding: 0 0.9rem 0.9rem 3.1rem;
  background: var(--paper);
  box-shadow: inset 3px 0 0 var(--brass);
}

.live-picker[hidden] {
  display: none;
}

.case-dot {
  grid-row: span 2;
  align-self: start;
  margin-top: 0.42rem;
  width: 0.62rem;
  height: 0.62rem;
  border: 1px solid var(--muted);
  border-radius: 50%;
}

.case-input:checked + .case-label .case-dot {
  border-color: var(--brass);
  background: var(--brass);
  box-shadow: inset 0 0 0 2px var(--leaf);
}

.case-name {
  font-weight: 600;
  font-size: 0.93rem;
  line-height: 1.35;
}

.case-desc {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

.case-desc code {
  font-family: var(--mono);
  font-size: 0.95em;
}

.case-origin {
  display: inline-block;
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.05rem 0.32rem;
}

.case-origin[data-origin="live"] {
  color: var(--brass);
  border-color: rgba(122, 95, 30, 0.45);
}

/* -------------------------------------------------------------- byte field */

.bytefield {
  margin: 0 0 1.4rem;
  display: grid;
  gap: 0.55rem;
}

.byterow {
  display: grid;
  grid-template-columns: 7.5rem 1fr 8.5rem;
  align-items: center;
  gap: 0.9rem;
}

@media (max-width: 40rem) {
  .byterow {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

.byterow-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.byterow-count {
  font-family: var(--mono);
  font-size: 0.82rem;
  text-align: right;
}

@media (max-width: 40rem) {
  .byterow-count {
    text-align: left;
  }
}

.bar {
  position: relative;
  height: 2.6rem;
  border: 1px solid var(--rule);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 5px,
    rgba(90, 100, 104, 0.16) 5px,
    rgba(90, 100, 104, 0.16) 6px
  );
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: var(--graphite);
  transition: width 900ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-fill[data-verdict="fail"] {
  background: var(--oxide);
}

.bar-fill[data-verdict="pass"] {
  background: var(--brass);
}

.bar-disc {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brass-bright);
}

.bytefield-void {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--oxide);
  min-height: 1.3em;
}

.bytefield-void:empty {
  min-height: 0;
}

/* ---------------------------------------------------------------- readout */

.readout {
  background: var(--graphite);
  color: #d7dbdc;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.75;
  padding: 1.1rem 1.2rem;
  margin: 0;
  min-height: 11rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.readout code {
  display: block;
  font-family: inherit;
}

.line-head {
  color: #fff;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.line-pass {
  color: var(--brass-bright);
}

.line-fail {
  color: var(--oxide-bright);
}

.line-muted {
  color: var(--slate-bright);
}

.line-exit-ok {
  color: var(--brass-bright);
  font-weight: 600;
}

.line-exit-bad {
  color: var(--oxide-bright);
  font-weight: 600;
}

.line-exit-skip {
  color: var(--slate-bright);
  font-weight: 600;
}

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

.run-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
}

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--leaf);
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease;
}

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

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

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

.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}

.btn-quiet:hover {
  background: transparent;
  border-color: var(--brass);
  color: var(--brass);
}

.run-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}

.advanced {
  border-top: 1px solid var(--rule);
  margin-top: 1.4rem;
  padding-top: 1rem;
}

.advanced > summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.advanced > summary::-webkit-details-marker {
  display: none;
}

.advanced > summary::after {
  content: "open";
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
}

.advanced[open] > summary::after {
  content: "close";
}

.advanced-body {
  display: grid;
  gap: 1.1rem;
  padding-top: 1.1rem;
}

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

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

.field input,
.field select,
.field textarea {
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--ink);
  background: var(--leaf);
  border: 1px solid var(--rule);
  padding: 0.6rem 0.7rem;
  width: 100%;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #93999a;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 2px rgba(122, 95, 30, 0.2);
}

.field-hint {
  margin: 0;
  font-size: 0.79rem;
  line-height: 1.5;
  color: var(--muted);
}

.field-hint code,
.run-hint code {
  font-family: var(--mono);
  font-size: 0.95em;
}

/* ----------------------------------------------------------------- ladder */

.section {
  padding: clamp(3rem, 7vw, 5rem) 0;
  border-top: 1px solid var(--rule);
}

.section-title {
  margin: 0 0 0.6rem;
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 800;
  font-stretch: 112%;
  letter-spacing: -0.02em;
}

.section-lede {
  margin: 0 0 2rem;
  max-width: 58ch;
  color: var(--muted);
}

.ladder {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 48rem;
}

.rung {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0 1.2rem;
  padding-bottom: 1.6rem;
  position: relative;
}

.rung:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 1.45rem;
  top: 1.9rem;
  bottom: 0;
  width: 1px;
  background: var(--rule);
}

.rung-num {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--rule);
  background: var(--paper);
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
}

.rung-name {
  margin: 0;
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 2rem;
}

.rung-desc {
  margin: 0.15rem 0 0;
  grid-column: 2;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 52ch;
}

.rung-branch {
  grid-column: 2;
  margin: 0.7rem 0 0;
  padding: 0.5rem 0.8rem;
  border-left: 2px solid var(--oxide);
  background: rgba(163, 48, 31, 0.05);
  font-size: 0.87rem;
  color: var(--ink);
  max-width: 52ch;
}

/* ----------------------------------------------------------------- deploy */

.codeblock {
  position: relative;
  margin: 0 0 1rem;
  max-width: 48rem;
}

.codeblock pre {
  margin: 0;
  background: var(--graphite);
  color: #d7dbdc;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.7;
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
}

.copy-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #aab2b4;
  background: transparent;
  border: 1px solid #333a3d;
  padding: 0.22rem 0.5rem;
  cursor: pointer;
}

.copy-btn:hover {
  color: var(--brass-bright);
  border-color: var(--brass-bright);
}

.sub-title {
  margin: 2.2rem 0 0.6rem;
  font-size: 1.05rem;
  font-weight: 700;
}

/* ----------------------------------------------------------------- footer */

footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 0 3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

footer .shell {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------------- motion */

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

  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}

/* ------------------------------------------------- appended: prose inline code */

/* The inline-code rule above covers .field-hint, .run-hint and .case-desc only,
   so <code> inside section ledes and ladder rungs fell back to the browser's
   default monospace at full body size. */
.section-lede code,
.rung-desc code {
  font-family: var(--mono);
  font-size: 0.95em;
}
