/* The homepage: the scripted messenger, Fig. 1, the chapters, the index and pricing. base.css comes first. */

/* Opening */

.opening {
  padding-block: 1.5rem 5rem;
}

.opening-grid {
  display: grid;
  align-items: start;
  gap: 3rem 4rem;
  margin-top: 3.5rem;
  grid-template-columns: minmax(0, 1fr) 23rem;
}

.dek {
  max-width: 33rem;
  margin-top: 1.5rem;
  color: var(--ink-2);
  font-size: 1.25rem;
  line-height: 1.45;
  text-wrap: pretty;
}

@media (max-width: 56rem) {
  .opening-grid {
    margin-top: 2.5rem;
    grid-template-columns: minmax(0, 1fr);
  }

  .demo {
    max-width: 26rem;
  }
}

/* The scripted messenger. It uses the product's sans, since it stands in for the real one. */

.messenger {
  overflow: hidden;
  border: 1px solid #00000017;
  border-radius: 1rem;
  background: #fff;
  box-shadow:
    0 1px 0 #0000000d,
    0 2rem 4rem -2rem #3b2a1666;
  font-family: var(--ui);
  font-size: 0.875rem;
  line-height: 1.45;
}

.messenger-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid #0000000f;
}

.messenger-head img {
  width: 1.75rem;
  height: 1.75rem;
}

.messenger-head strong {
  display: block;
  font-weight: 600;
}

.messenger-head small {
  color: var(--ink-3);
  font-size: 0.75rem;
}

.messenger-log {
  display: flex;
  height: 21.5rem;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.875rem;
  overflow-y: auto;
  scrollbar-width: thin;
}

.bubble {
  max-width: 88%;
  padding: 0.55rem 0.8rem;
  border-radius: 0.875rem;
  text-wrap: pretty;
}

.bubble.user {
  align-self: flex-end;
  border-bottom-right-radius: 0.25rem;
  background: var(--ink);
  color: #fff;
}

.bubble.agent {
  align-self: flex-start;
  border-bottom-left-radius: 0.25rem;
  background: #f4efe6;
}

.bubble.teammate {
  align-self: flex-start;
  border: 1px solid var(--ink);
  border-bottom-left-radius: 0.25rem;
  background: #fff;
}

.bubble small {
  display: block;
  margin-top: 0.25rem;
  color: var(--ink-3);
  font-size: 0.75rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-3);
  font-size: 0.75rem;
}

.step::before {
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  border: 1.5px solid var(--thread);
  border-radius: 50%;
  content: '';
}

.step.running::before {
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

.plan-card,
.snippet-card,
.ask {
  border: 1px solid #e4dccd;
  border-radius: 0.75rem;
}

.plan-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
}

.plan-card small {
  display: block;
  color: var(--ink-3);
  font-size: 0.75rem;
}

.plan-price {
  font-family: var(--serif);
  font-size: 1.625rem;
}

.plan-price small {
  display: inline;
  font-family: var(--ui);
}

.snippet-card {
  padding: 0.75rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  white-space: pre-wrap;
}

.ask {
  padding: 0.75rem;
  border: 1.5px solid var(--ink);
}

.ask strong {
  display: block;
  font-weight: 600;
}

.ask span {
  color: var(--ink-2);
  font-size: 0.8125rem;
}

.ask-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.625rem;
}

.ask-buttons button {
  padding: 0.375rem 0.75rem;
  border: 1px solid #0000001f;
  border-radius: 0.5rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
}

.ask-buttons button:first-child {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.ask-buttons button:disabled {
  cursor: default;
  opacity: 0.45;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.75rem 0.875rem 0.875rem;
  border-top: 1px solid #0000000f;
}

.suggestions a {
  padding: 0.3rem 0.65rem;
  border: 1px solid #e4dccd;
  border-radius: 99px;
  color: var(--ink-2);
  font-size: 0.75rem;
  text-decoration: none;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.suggestions a:hover,
.suggestions a[aria-current='true'] {
  border-color: var(--ink);
  color: var(--ink);
}

.margin-note {
  margin-top: 0.875rem;
  padding-left: 0.875rem;
  border-left: 2px solid var(--thread);
  color: var(--ink-3);
  font-size: 0.9375rem;
  font-style: italic;
  line-height: 1.4;
}

/* Hidden until home.js has taken the messenger over, so the starting text doesn't flash. */
.js .messenger-log:not(.live) {
  visibility: hidden;
}

/* A recording of the real messenger, after the scripted one in the opening */

.recorded {
  padding-block: 4.5rem 5rem;
  border-top: 1px solid var(--ink);
}

.recorded h2 {
  max-width: 16em;
  margin-top: 0.75rem;
}

.recorded .recording {
  margin-top: 2.5rem;
}

/* Fig. 1, the stitched trace */

.figure-one {
  padding-block: 4.5rem 5rem;
  border-top: 1px solid var(--ink);
  background: var(--sheet);
}

.figure-one h2 {
  max-width: 14em;
  margin-top: 0.75rem;
}

.trace {
  position: relative;
  margin-top: 3.5rem;
}

/* The thread runs down between the margin and the text, through a hole at each step. */
.trace::before {
  position: absolute;
  top: 0.5rem;
  bottom: 1.5rem;
  left: calc(var(--margin) + 1.5rem);
  width: 2px;
  background: repeating-linear-gradient(to bottom, var(--thread) 0 0.8rem, transparent 0.8rem 1.3rem);
  content: '';
  transform-origin: top;
}

.js .trace::before {
  transform: scaleY(0);
}

.js .trace.sewn::before {
  transform: scaleY(1);
  transition: transform 3.2s cubic-bezier(0.6, 0.1, 0.3, 1);
}

.trace > li {
  position: relative;
  display: grid;
  gap: 0 3rem;
  padding-bottom: 2rem;
  grid-template-columns: var(--margin) minmax(0, 1fr);
}

.trace > li::before {
  position: absolute;
  top: 0.45rem;
  left: calc(var(--margin) + 1.5rem - 0.3rem + 1px);
  width: 0.6rem;
  height: 0.6rem;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--sheet);
  content: '';
}

.trace-when {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  line-height: 1.6;
  text-align: right;
  text-transform: uppercase;
}

.trace-when span {
  display: block;
  color: var(--ink);
}

.trace-quote {
  font-size: clamp(1.5rem, 3vw, 1.875rem);
  font-style: italic;
  font-weight: 350;
  line-height: 1.15;
}

.trace-meta {
  margin-top: 0.5rem;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.trace .mono + .mono,
.chips {
  margin-top: 0.375rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.chip {
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.chip.read {
  border-color: var(--ink);
}

.trace-answer {
  max-width: 28em;
  font-size: clamp(1.25rem, 2.4vw, 1.4375rem);
  line-height: 1.35;
}

sup {
  padding-left: 0.1em;
  color: var(--thread);
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 0;
}

.footnotes {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.5rem;
  padding: 1rem 0 0 calc(var(--margin) + 3rem);
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.footnotes sup {
  padding: 0 0.375rem 0 0;
}

.footnotes p:last-child {
  margin-top: 0.75rem;
  font-style: italic;
}

@media (max-width: 44rem) {
  .trace::before {
    left: 0.3rem;
  }

  .trace > li {
    padding-left: 2rem;
    grid-template-columns: minmax(0, 1fr);
  }

  .trace > li::before {
    left: 0;
  }

  .trace-when {
    margin-bottom: 0.25rem;
    text-align: left;
  }

  .trace-when span {
    display: inline;
    margin-left: 0.5rem;
  }

  .footnotes {
    padding-left: 0;
  }
}

/* Chapters. One thread runs down the left margin through every chapter numeral, sewn as you scroll. */

.chapters {
  position: relative;
  border-top: 1px solid var(--ink);
}

.chapters::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: max(1.5rem, (100% - 66rem) / 2);
  width: 2px;
  margin-left: calc(var(--margin) / 2 - 1px);
  background: repeating-linear-gradient(to bottom, var(--thread) 0 0.8rem, transparent 0.8rem 1.3rem);
  content: '';
  transform: scaleY(var(--sewn, 1));
  transform-origin: top;
}

.chapter {
  position: relative;
  padding-block: 5rem;
}

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

.chapter-head {
  display: grid;
  align-items: start;
  grid-template-columns: var(--margin) minmax(0, 1fr);
}

.numeral {
  position: relative;
  z-index: 1;
  justify-self: center;
  min-width: 3.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--paper);
  font-size: 2.25rem;
  font-style: italic;
  font-weight: 350;
  line-height: 1;
  text-align: center;
}

.chapter-head h2 {
  max-width: 17em;
  margin-top: 0.75rem;
}

/* Figures are plates: a sheet or two on the paper, with a caption underneath. */
.plate {
  display: grid;
  gap: 1.25rem;
  margin: 3rem 0 0 var(--margin);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.plate figcaption {
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-style: italic;
  grid-column: 1 / -1;
}

.sheet {
  padding: 1.25rem;
  border: 1px solid var(--ink);
  background: var(--sheet);
  box-shadow: 4px 4px 0 var(--rule);
}

.sheet-title {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.sheet-title strong {
  font-size: 1.1875rem;
  font-weight: 500;
}

.sheet-title span {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.ink {
  overflow-x: auto;
  padding: 1.25rem;
  background: var(--ink);
  color: #e9e3d6;
  line-height: 1.6;
}

.ink .faint {
  color: #8f877a;
}

.ink .hl {
  color: #fff;
  font-weight: 500;
}

.ink .bad {
  color: #ff8a6e;
}

.settings > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.625rem;
  font-size: 1rem;
}

.settings > div + div {
  border-top: 1px dashed var(--rule);
}

.settings dd {
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 0.75rem;
  text-align: right;
}

.settings dd.on {
  color: var(--thread);
}

.plate-knowledge {
  grid-template-columns: 14rem minmax(0, 1fr);
}

.contents {
  align-self: start;
  font-size: 1rem;
}

.contents li {
  padding: 0.3rem 0;
  border-bottom: 1px dotted var(--rule);
}

.contents .open {
  font-weight: 500;
}

.contents .sub {
  padding-left: 1rem;
  color: var(--ink-2);
}

.contents .current {
  color: var(--thread);
  font-style: italic;
}

.article h3,
.manuscript h3 {
  margin: 0.75rem 0 0.25rem;
  font-size: 1.0625rem;
  font-weight: 500;
}

.article p {
  color: var(--ink-2);
  font-size: 1rem;
}

.skill-list li {
  display: grid;
  padding: 0.75rem 0;
  border-bottom: 1px dotted var(--rule);
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.skill-list li:first-child {
  padding-top: 0;
}

.skill-list strong {
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 500;
}

.skill-list em {
  margin-left: 0.5rem;
  color: var(--thread);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.manuscript {
  font-size: 1rem;
}

.manuscript h3 {
  margin-top: 0;
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 400;
}

.manuscript ol {
  padding-left: 1.25rem;
  margin-block: 0.5rem;
  list-style: decimal;
}

.manuscript p + p {
  margin-top: 0.5rem;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #fff;
  font-family: var(--ui);
  font-size: 0.875rem;
  line-height: 1.45;
}

.run-card {
  display: grid;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem;
  border: 1px solid #e4dccd;
  border-radius: 0.75rem;
  grid-template-columns: 1fr auto;
}

.run-card small {
  display: block;
  color: var(--ink-3);
  font-size: 0.75rem;
}

.run-card .status {
  color: var(--thread);
  font-size: 0.75rem;
  font-weight: 600;
}

.run-button {
  padding: 0.4rem;
  border-radius: 0.5rem;
  background: var(--ink);
  color: #fff;
  font-size: 0.8125rem;
  grid-column: 1 / -1;
  text-align: center;
}

.threads li {
  display: grid;
  padding: 0.75rem 0.75rem;
  border-bottom: 1px dotted var(--rule);
  font-size: 0.9375rem;
}

.threads li.current {
  border: 1px solid var(--ink);
  background: var(--sheet);
}

.threads strong {
  font-weight: 500;
}

.threads span {
  color: var(--ink-2);
}

.threads em {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.threads em.flag {
  color: var(--thread);
}

.plate-embed {
  grid-template-columns: minmax(0, 1fr);
}

/* The two snippets switch with radio buttons, so they work without script. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  max-width: 40rem;
}

.tabs input {
  position: absolute;
  opacity: 0;
}

.tabs label {
  padding: 0.5rem 1rem;
  border: 1px solid var(--ink);
  border-bottom: 0;
  margin-right: -1px;
  color: var(--ink-2);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.tabs input:checked + label {
  background: var(--ink);
  color: var(--paper);
}

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

.tabs pre {
  display: none;
  width: 100%;
}

#snippet-html:checked ~ .snippet-html,
#snippet-react:checked ~ .snippet-react {
  display: block;
}

@media (max-width: 44rem) {
  :root {
    --margin: 3rem;
  }

  .chapters::before {
    margin-left: calc(var(--margin) / 2 - 1px);
  }

  .chapter {
    padding-block: 3.5rem;
  }

  .chapter-head {
    gap: 0;
  }

  .numeral {
    min-width: 0;
    padding-inline: 0.25rem;
    font-size: 1.5rem;
  }

  .plate,
  .plate-knowledge {
    margin-top: 2rem;
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Index */

.index-section {
  padding-block: 5rem;
  border-top: 1px solid var(--ink);
}

.index-section h2 {
  margin-top: 0.75rem;
}

.index {
  margin-top: 2.5rem;
  columns: 2 22rem;
  column-gap: 4rem;
}

.index li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding-block: 0.4rem;
  break-inside: avoid;
  font-size: 1.0625rem;
}

/* Dot leaders between the entry and where it lives, like a book's index. */
.index li::after {
  flex: 1;
  border-bottom: 1.5px dotted var(--ink-3);
  content: '';
  order: 1;
}

.index li > :last-child {
  order: 2;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

.index a {
  text-decoration-color: var(--thread);
  text-underline-offset: 0.25em;
}

.index .soon {
  color: var(--ink-3);
}

/* Closing: pricing as a ledger */

.closing {
  padding-block: 5rem 6rem;
  border-top: 1px solid var(--ink);
  background: var(--sheet);
}

.closing h2 {
  margin-top: 0.75rem;
}

.ledger {
  width: 100%;
  margin-top: 2.5rem;
  border-collapse: collapse;
  font-size: 1.0625rem;
}

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

.ledger thead th {
  padding-block: 0 0.5rem;
  border-bottom: 1px solid var(--ink);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ledger tbody th {
  font-size: 1.375rem;
  font-style: italic;
  font-weight: 400;
}

.ledger td:last-child,
.ledger thead th:last-child {
  padding-right: 0;
  text-align: right;
}

.ledger strong {
  font-size: 1.625rem;
  font-weight: 400;
}

.ledger small {
  display: block;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 0.6875rem;
}

.ledger a {
  text-decoration-color: var(--thread);
  text-underline-offset: 0.25em;
}

@media (max-width: 44rem) {
  .ledger thead {
    display: none;
  }

  .ledger tr {
    display: grid;
    padding-block: 0.75rem;
    border-bottom: 1px solid var(--rule);
    grid-template-columns: 1fr auto;
  }

  .ledger th,
  .ledger td {
    padding: 0;
    border: 0;
  }

  .ledger td:nth-child(2),
  .ledger td:nth-child(3) {
    color: var(--ink-2);
    font-size: 0.9375rem;
    grid-column: 1;
  }

  .ledger td:last-child {
    grid-column: 2;
    grid-row: 1 / span 3;
  }
}

/* Flashed when the agent moves the page to a section, so it's clear where it went. */
.arrived {
  animation: arrived 2.4s ease-out;
}

@keyframes arrived {
  0%,
  40% {
    box-shadow: inset 4px 0 0 var(--thread);
  }

  100% {
    box-shadow: inset 4px 0 0 transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .trace::before {
    transform: none;
  }

  .chapters::before {
    transform: none;
  }

  .step.running::before {
    animation: none;
  }
}

/* The approval card in the actions plate is a picture of one, so its buttons are spans styled like the demo's. */
.plate .ask-buttons span {
  padding: 0.375rem 0.75rem;
  border: 1px solid #0000001f;
  border-radius: 0.5rem;
  background: #fff;
  color: var(--ink);
}

.plate .ask-buttons span:first-child {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
