/* vitrina — see DESIGN.md for why light, why restrained, why mono for data. */

:root {
  --paper: oklch(98.6% 0.004 95);
  --panel: oklch(96.8% 0.006 95);
  --raise: oklch(99.4% 0.003 95);
  --sunk: oklch(94.6% 0.007 95);

  --ink: oklch(24% 0.016 250);
  --ink-2: oklch(46% 0.014 250);
  --ink-3: oklch(62% 0.012 250);

  --rule: oklch(89% 0.008 250);
  --rule-strong: oklch(82% 0.01 250);

  --accent: oklch(45% 0.095 205);
  --accent-soft: oklch(94% 0.024 205);
  --accent-ink: oklch(99% 0.004 205);

  --pass: oklch(50% 0.105 152);
  --pass-soft: oklch(95% 0.03 152);
  --fail: oklch(52% 0.17 26);
  --fail-soft: oklch(95.5% 0.032 26);
  --write: oklch(56% 0.125 62);
  --write-soft: oklch(95.5% 0.045 62);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --t-xs: 0.75rem;
  --t-sm: 0.8125rem;
  --t-ms: 0.875rem;
  --t-md: 1rem;
  --t-lg: 1.125rem;
  --t-xl: 1.375rem;
  --t-2xl: 1.75rem;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  --r-sm: 5px;
  --r-md: 9px;
  --r-lg: 14px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 150ms;
  --med: 220ms;

  --rail-w: 27rem;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Numbers must not jitter as they update. */
.mono,
code,
pre,
.sku,
.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

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

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

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

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

/* ============================================================ gate */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s-5);
}

.gate-card {
  width: min(30rem, 100%);
}

.gate-mark {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin-bottom: var(--s-5);
}

.gate h1 {
  font-size: var(--t-2xl);
  letter-spacing: -0.02em;
  margin: 0 0 var(--s-3);
  font-weight: 600;
}

.gate p {
  color: var(--ink-2);
  margin: 0 0 var(--s-5);
  max-width: 62ch;
}

.gate form {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.field {
  flex: 1 1 12rem;
  min-width: 0;
}

.field label {
  display: block;
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-2);
  margin-bottom: var(--s-1);
  font-weight: 600;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s-3);
  background: var(--raise);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-md);
  transition: border-color var(--fast) var(--ease);
}

input[type="password"]:hover,
input[type="text"]:hover {
  border-color: var(--ink-3);
}

input[type="password"]:focus-visible,
input[type="text"]:focus-visible {
  border-color: var(--accent);
  outline-offset: 1px;
}

.gate-error {
  flex: 1 0 100%;
  margin: var(--s-2) 0 0;
  color: var(--fail);
  font-size: var(--t-ms);
  min-height: 1.4em;
}

.gate-foot {
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule);
  font-size: var(--t-sm);
  color: var(--ink-3);
}

/* ============================================================ buttons */

.btn {
  --btn-bg: var(--raise);
  --btn-fg: var(--ink);
  --btn-bd: var(--rule-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-4);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-md);
  font-size: var(--t-ms);
  font-weight: 550;
  cursor: pointer;
  transition:
    background var(--fast) var(--ease),
    border-color var(--fast) var(--ease),
    transform var(--fast) var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--sunk);
}

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

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

.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-ink);
  --btn-bd: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: oklch(39% 0.095 205);
}

.btn-sm {
  min-height: 34px;
  padding: 0 var(--s-3);
  font-size: var(--t-sm);
}

.btn-quiet {
  --btn-bd: transparent;
  --btn-bg: transparent;
  color: var(--ink-2);
}

.btn-quiet:hover:not(:disabled) {
  color: var(--ink);
}

.spin {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  flex: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================ shell */

.shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin-right: auto;
  min-width: 0;
}

.wordmark strong {
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.015em;
}

.wordmark span {
  font-size: var(--t-sm);
  color: var(--ink-2);
}

.mark {
  width: 22px;
  height: 22px;
  flex: none;
  align-self: center;
  color: var(--accent);
}

.split {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail-w);
  align-items: stretch;
  min-height: 0;
}

.thread {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--rule);
}

.rail {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ============================================================ transcript */

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  scroll-behavior: smooth;
}

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

.turn {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-width: 46rem;
  animation: rise var(--med) var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.turn.from-customer {
  align-self: flex-end;
  align-items: flex-end;
}

.who {
  font-size: var(--t-xs);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}

.bubble {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--rule);
  background: var(--raise);
  max-width: 68ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.from-customer .bubble {
  background: var(--accent-soft);
  border-color: oklch(87% 0.04 205);
}

.thinking {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-ms);
  color: var(--ink-2);
}

.dots {
  display: inline-flex;
  gap: 3px;
}

.dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: pulse 1.1s var(--ease) infinite;
}

.dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.dots i:nth-child(3) {
  animation-delay: 0.3s;
}

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

/* ---- product cards: the one place a card is the right affordance ---- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--s-3);
  width: 100%;
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--raise);
  overflow: hidden;
}

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--sunk);
}

.card-body {
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  flex: 1;
}

.card h3 {
  margin: 0;
  font-size: var(--t-ms);
  font-weight: 600;
  line-height: 1.35;
}

.card-meta {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.price {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: var(--t-ms);
}

.card-desc {
  margin: 0;
  font-size: var(--t-sm);
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  margin-top: auto;
  display: flex;
  gap: var(--s-2);
  padding-top: var(--s-1);
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  padding: 2px var(--s-2);
  border-radius: 999px;
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.pill.in {
  background: var(--pass-soft);
  color: var(--pass);
}

.pill.low {
  background: var(--write-soft);
  color: var(--write);
}

.pill.out {
  background: var(--fail-soft);
  color: var(--fail);
}

/* ============================================================ composer */

.composer {
  border-top: 1px solid var(--rule);
  padding: var(--s-3) var(--s-5) var(--s-4);
  background: var(--paper);
}

.composer-locked {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-ms);
  color: var(--ink-2);
  flex-wrap: wrap;
}

.composer form {
  display: flex;
  gap: var(--s-2);
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 8rem;
  padding: var(--s-3);
  resize: none;
  background: var(--raise);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-md);
  transition: border-color var(--fast) var(--ease);
}

.composer textarea:hover {
  border-color: var(--ink-3);
}

.composer textarea:focus-visible {
  border-color: var(--accent);
  outline-offset: 1px;
}

.hint {
  margin: var(--s-2) 0 0;
  font-size: var(--t-xs);
  color: var(--ink-3);
}

.suggestions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}

/* ============================================================ rail */

.rail-head {
  padding: var(--s-4) var(--s-4) var(--s-3);
  border-bottom: 1px solid var(--rule);
}

.rail-head h2 {
  margin: 0;
  font-size: var(--t-ms);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.rail-head p {
  margin: var(--s-1) 0 0;
  font-size: var(--t-sm);
  color: var(--ink-2);
}

.rail-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.section-label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-4) var(--s-2);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--ink-3);
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* ---- tour ledger ---- */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.step {
  border-bottom: 1px solid var(--rule);
  padding: var(--s-3) var(--s-4);
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr);
  gap: var(--s-1) var(--s-3);
  color: var(--ink-3);
  transition: background var(--med) var(--ease);
}

.step[data-state="current"] {
  background: var(--raise);
  color: var(--ink);
}

.step[data-state="done"] {
  color: var(--ink-2);
}

.step-n {
  font-family: var(--mono);
  font-size: var(--t-sm);
  padding-top: 1px;
}

.step[data-state="current"] .step-n {
  color: var(--accent);
  font-weight: 700;
}

.step-title {
  font-size: var(--t-ms);
  font-weight: 600;
  margin: 0;
  color: inherit;
}

.step-brief,
.step-proves {
  grid-column: 2;
  margin: 0;
  font-size: var(--t-sm);
}

.step-brief {
  color: var(--ink-2);
}

.step-proves {
  color: var(--ink-3);
  font-style: italic;
}

/* Pending steps show their title only, so the rail reads as a contents list rather
   than a wall of text, and each step's message is revealed as it comes up. */
.step[data-state="pending"] .step-brief,
.step[data-state="pending"] .step-proves,
.step[data-state="pending"] .step-say {
  display: none;
}

.step-say {
  grid-column: 2;
  margin: var(--s-1) 0 0;
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--ink-2);
  background: var(--sunk);
  border-radius: var(--r-sm);
  padding: var(--s-2);
}

.checks {
  grid-column: 2;
  list-style: none;
  margin: var(--s-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.check {
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr);
  gap: var(--s-2);
  font-size: var(--t-sm);
  animation: rise var(--fast) var(--ease) both;
}

.check-icon {
  width: 15px;
  height: 15px;
  margin-top: 3px;
}

.check[data-r="pass"] .check-icon {
  color: var(--pass);
}

.check[data-r="fail"] .check-icon {
  color: var(--fail);
}

.check[data-r="wait"] .check-icon {
  color: var(--ink-3);
}

.check-label {
  color: var(--ink);
}

.check[data-r="fail"] .check-label {
  color: var(--fail);
}

.check-detail {
  display: block;
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.step-actions {
  grid-column: 2;
  margin-top: var(--s-3);
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

/* ---- trace ledger ---- */

.trace {
  padding: 0 0 var(--s-5);
}

.trace-turn {
  border-bottom: 1px solid var(--rule);
}

.trace-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4) var(--s-2);
  flex-wrap: wrap;
}

.trace-q {
  font-size: var(--t-sm);
  color: var(--ink-2);
  flex: 1 1 12rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tag {
  font-family: var(--mono);
  font-size: var(--t-xs);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--rule-strong);
  color: var(--ink-2);
  white-space: nowrap;
}

.tag.ok {
  color: var(--pass);
  border-color: oklch(84% 0.06 152);
  background: var(--pass-soft);
}

.tag.warn {
  color: var(--write);
  border-color: oklch(85% 0.07 62);
  background: var(--write-soft);
}

.tag.bad {
  color: var(--fail);
  border-color: oklch(85% 0.08 26);
  background: var(--fail-soft);
}

.tools {
  list-style: none;
  margin: 0;
  padding: 0 var(--s-4) var(--s-3);
  display: flex;
  flex-direction: column;
}

.tool {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 var(--s-3);
  padding: var(--s-2) 0;
  border-top: 1px dotted var(--rule);
  animation: rise var(--fast) var(--ease) both;
}

.tool:first-child {
  border-top: 0;
}

.tool-name {
  font-family: var(--mono);
  font-size: var(--t-sm);
  font-weight: 600;
}

.tool[data-write="1"] .tool-name {
  color: var(--write);
}

.tool[data-write="1"] .tool-name::after {
  content: "writes";
  margin-left: var(--s-2);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: var(--r-sm);
  background: var(--write-soft);
  vertical-align: 1px;
}

.tool-ms {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-xs);
  color: var(--ink-3);
  text-align: right;
  white-space: nowrap;
}

.tool-args,
.tool-out {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: var(--t-xs);
  overflow-wrap: anywhere;
  margin: 2px 0 0;
}

.tool-args {
  color: var(--accent);
}

.tool-out {
  color: var(--ink-2);
}

.empty {
  padding: var(--s-4);
  font-size: var(--t-sm);
  color: var(--ink-3);
  margin: 0;
}

/* ---- payload viewer ---- */

.seg {
  display: flex;
  gap: 2px;
  padding: 0 var(--s-4) var(--s-2);
}

.seg button {
  flex: 1;
  min-height: 34px;
  padding: 0 var(--s-2);
  font-size: var(--t-xs);
  font-weight: 600;
  background: var(--sunk);
  color: var(--ink-2);
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.seg button:first-child {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

.seg button:last-child {
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.seg button:hover {
  color: var(--ink);
}

.seg button[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

pre.payload {
  margin: 0 var(--s-4) var(--s-4);
  padding: var(--s-3);
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  font-size: var(--t-xs);
  line-height: 1.5;
  overflow-x: auto;
  max-height: 22rem;
  overflow-y: auto;
  white-space: pre;
}

.payload-note {
  margin: 0 var(--s-4) var(--s-3);
  font-size: var(--t-sm);
  color: var(--ink-2);
}

/* ============================================================ toast */

.toast {
  position: fixed;
  inset-inline: 0;
  bottom: var(--s-5);
  margin-inline: auto;
  width: fit-content;
  max-width: calc(100% - 2 * var(--s-5));
  padding: var(--s-3) var(--s-4);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r-md);
  font-size: var(--t-ms);
  z-index: 60;
  animation: rise var(--med) var(--ease) both;
}

.toast[data-kind="error"] {
  background: var(--fail);
}

/* ============================================================ product page */

.product-page {
  padding: var(--s-6) var(--s-5);
}

.product {
  max-width: 46rem;
  margin: 0 auto;
  display: grid;
  gap: var(--s-5);
}

.product .back {
  font-size: var(--t-ms);
  text-decoration: none;
}

.product .back:hover {
  text-decoration: underline;
}

.product img {
  width: 100%;
  height: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--rule);
}

.product-body {
  display: grid;
  gap: var(--s-3);
}

.product .sku {
  margin: 0;
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.product h1 {
  margin: 0;
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.product .price {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: 0;
  font-size: var(--t-lg);
}

.product .desc {
  margin: 0;
  max-width: 68ch;
  color: var(--ink-2);
}

.attrs {
  margin: 0;
  padding: var(--s-3) 0 0;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: var(--s-2) var(--s-5);
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.attr {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px dotted var(--rule);
  font-size: var(--t-ms);
}

.attr dt {
  color: var(--ink-2);
}

.attr dd {
  margin: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.product .note {
  margin: 0;
  font-size: var(--t-sm);
  color: var(--ink-3);
}

/* ============================================================ responsive */

@media (max-width: 60rem) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .thread {
    border-right: 0;
  }

  .rail {
    border-top: 1px solid var(--rule);
  }

  .transcript {
    padding: var(--s-4);
  }

  .composer {
    padding: var(--s-3) var(--s-4) var(--s-4);
  }
}

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