/* Market Lab guide: a docs layout (contents sidebar, reading column,
   featured rail) with screenshots and numbered callouts that match the red
   boxes drawn on each picture. */

.docs-document {
  --guide-callout: #e0001b;
  --docs-sticky-top: calc(var(--header-height) + 28px);
  --docs-muted: rgba(0, 23, 31, 0.64);
}

/* The sheet hangs off the site header like the other reading pages. */
.docs {
  border: 2px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 4px 4px;
  background: var(--paper);
}

.docs a {
  color: inherit;
}

/* Top bar: title, search, date. */
.docs-bar {
  display: grid;
  grid-template-columns: 1fr minmax(0, 420px) 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(16px, 2.4vw, 28px);
  border-bottom: 1px solid var(--rule-soft);
}

.docs-bar__title {
  font-weight: 600;
  text-decoration: none;
}

.docs-bar__date {
  margin: 0;
  justify-self: end;
  color: var(--docs-muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.docs-search {
  position: relative;
}

.docs-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 15px;
  height: 15px;
  translate: 0 -50%;
  fill: none;
  stroke: var(--docs-muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  pointer-events: none;
}

.docs-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--paper-muted);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
}

.docs-search input:focus {
  border-color: var(--purple-deep);
  outline: 2px solid var(--lavender);
  background: var(--paper);
}

/* Three columns: contents, reading column, featured links. */
.docs-layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 200px;
  gap: clamp(24px, 3vw, 48px);
  padding: 0 clamp(16px, 2.4vw, 28px);
}

.docs-nav,
.docs-rail {
  position: sticky;
  top: var(--docs-sticky-top);
  align-self: start;
  max-height: calc(100vh - var(--docs-sticky-top) - 16px);
  overflow-y: auto;
  padding: 28px 0 32px;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.docs-nav:hover,
.docs-rail:hover {
  scrollbar-color: var(--rule-soft) transparent;
}

.docs-nav summary {
  display: none;
}

.docs-nav ul,
.docs-rail ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-nav a,
.docs-rail a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.35;
  text-decoration: none;
}

.docs-nav a:hover,
.docs-nav a:focus-visible,
.docs-rail a:hover,
.docs-rail a:focus-visible {
  background: var(--paper-muted);
}

.docs-nav a[aria-current="true"] {
  background: var(--lavender);
  color: var(--purple-deep);
  font-weight: 600;
}

.docs-nav li span {
  flex: none;
  min-width: 1.6em;
  color: var(--docs-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.docs-nav a[aria-current="true"] span {
  color: inherit;
}

.docs-nav__pinned {
  margin-bottom: 12px !important;
}

.docs-nav__pinned a {
  padding-block: 6px;
}

.docs-nav__icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.docs-nav__pinned .docs-nav__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  background: var(--paper-muted);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.8rem;
}

.docs-nav__ext {
  width: 13px;
  height: 13px;
  margin-left: auto;
  fill: none;
  stroke: var(--docs-muted);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.docs-nav__group,
.docs-rail__title {
  margin: 18px 0 6px;
  padding-left: 8px;
  color: var(--docs-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-nav__empty,
.docs-rail__note {
  padding-left: 8px;
  color: var(--docs-muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.docs-rail__note a {
  display: inline;
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Reading column. */
.docs-main {
  /* Auto margins alone would size the column to its widest screenshot. */
  width: 100%;
  min-width: 0;
  max-width: 780px;
  margin-inline: auto;
  padding: clamp(28px, 4vw, 56px) 0 48px;
}

.docs-hero {
  display: grid;
  justify-items: center;
  padding-bottom: clamp(28px, 4vw, 44px);
  text-align: center;
}

.docs-hero__mark {
  display: grid;
  place-items: center;
  width: clamp(120px, 14vw, 168px);
  aspect-ratio: 1;
  margin-bottom: 24px;
  border-radius: 50%;
  background: var(--lavender);
  color: var(--purple-deep);
}

.docs-hero__mark svg {
  width: 66%;
}

.docs-hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2.2rem, 4.2vw, 3.4rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
}

.docs-hero p {
  max-width: 34ch;
  margin: 0 0 24px;
  color: var(--docs-muted);
  font-size: 1.1rem;
  line-height: 1.5;
}

.docs-hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.docs-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
}

.docs-button svg,
.docs-card__more svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.docs-button:hover,
.docs-button:focus-visible {
  background: var(--paper-muted);
}

.docs-button--primary {
  border-color: var(--purple-deep);
  background: var(--purple-deep);
  color: var(--paper) !important;
}

.docs-button--primary:hover,
.docs-button--primary:focus-visible {
  border-color: var(--ink);
  background: var(--ink);
}

.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.docs-card {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 22px 24px;
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  text-decoration: none;
  transition: border-color 0.15s;
}

.docs-card:hover,
.docs-card:focus-visible {
  border-color: var(--purple-deep);
}

.docs-card__icon {
  width: 18px;
  height: 18px;
  margin-bottom: 6px;
  fill: var(--ink);
}

.docs-card h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.docs-card p {
  margin: 0;
  color: var(--docs-muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.docs-card__more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  color: var(--purple-deep);
  font-size: 0.92rem;
  font-weight: 600;
}

.docs-intro {
  padding-bottom: 8px;
  color: var(--docs-muted);
}

/* Step sections. */
.guide-body a {
  text-underline-offset: 3px;
}

.guide-body > section {
  padding-top: clamp(28px, 3.5vw, 44px);
  border-top: 1px solid var(--rule-soft);
  margin-top: clamp(28px, 3.5vw, 44px);
  /* Adds to the page's scroll-padding so a step lands level with the sidebar. */
  scroll-margin-top: 8px;
}

.guide-body > section[hidden] {
  display: none;
}

.guide-body > section > h2 {
  margin: 0 0 14px;
  font-size: clamp(1.5rem, 2.2vw, 1.9rem);
  font-weight: 500;
  line-height: 1.1;
}

.guide-body h3 {
  margin: 22px 0 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guide-body p,
.guide-body li {
  font-size: 1rem;
  line-height: 1.65;
}

.guide-body p {
  margin: 0 0 14px;
}

.guide-body > section > ul {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding-left: 1.2em;
}

.docs-meta {
  display: grid;
  gap: 14px;
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-soft);
  color: var(--docs-muted);
  font-size: 0.86rem;
}

.docs-meta a {
  color: var(--purple-deep);
  font-weight: 600;
}

.docs-meta p {
  margin: 0;
  font-size: inherit;
}

@media (max-width: 1180px) {
  .docs-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .docs-rail {
    display: none;
  }
}

/* Narrow screens: one column, contents fold into a disclosure. */
@media (max-width: 820px) {
  .docs-bar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .docs-bar__date {
    display: none;
  }

  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .docs-nav {
    position: static;
    max-height: none;
    padding: 12px 0 0;
    border-bottom: 1px solid var(--rule-soft);
  }

  .docs-nav summary {
    display: flex;
    justify-content: space-between;
    padding: 8px 0 12px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
  }

  .docs-nav summary::-webkit-details-marker {
    display: none;
  }

  .docs-nav summary::after {
    content: "+";
    font-family: var(--font-mono);
    font-weight: 500;
  }

  .docs-nav[open] summary::after {
    content: "\2212";
  }

  .docs-main {
    padding-top: 32px;
  }
}

.guide-step__number {
  display: inline-block;
  margin: 0 0 10px !important;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--lavender);
  color: var(--purple-deep);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.guide-shot {
  margin: 20px 0 18px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper-muted);
}

.guide-shot img {
  display: block;
  width: 100%;
  height: auto;
}

/* Small parts of the screen read better at a modest size. */
.guide-shot--narrow {
  max-width: 620px;
}

/* Numbered items that match the red boxes in the screenshot above. */
.guide-callouts {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  counter-reset: guide-callout;
}

.guide-callouts li {
  position: relative;
  padding-left: 40px;
  counter-increment: guide-callout;
}

.guide-callouts li::before {
  content: counter(guide-callout);
  position: absolute;
  top: 0.1em;
  left: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--guide-callout);
  box-shadow: 0 0 0 1px var(--guide-callout);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
}

.guide-glossary {
  display: grid;
  gap: 0;
  margin: 18px 0 0;
  border-top: 1px solid var(--rule-soft);
}

.guide-glossary > div {
  display: grid;
  grid-template-columns: minmax(130px, 11rem) minmax(0, 1fr);
  gap: 6px 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.guide-glossary dt {
  font-weight: 600;
}

.guide-glossary dd {
  margin: 0;
  line-height: 1.6;
}

.guide-glossary--compact {
  margin-bottom: 8px;
}

.guide-tip,
.guide-explainer {
  padding: 14px 16px;
  border-left: 4px solid var(--purple-deep);
  border-radius: 0 4px 4px 0;
  background: var(--lavender);
}

.guide-explainer h3 {
  margin-top: 0;
}

.guide-explainer p:last-child {
  margin-bottom: 0;
}

.guide-inline-icon {
  display: inline-grid;
  place-items: center;
  width: 1.3em;
  height: 1.3em;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 600;
  vertical-align: 0.05em;
}

.guide-disclaimer {
  margin-top: 22px !important;
  color: rgba(0, 23, 31, 0.72);
  font-size: 0.92rem !important;
}

@media (max-width: 640px) {
  .guide-glossary > div {
    grid-template-columns: 1fr;
  }

  .guide-callouts li {
    padding-left: 36px;
  }
}

.guide-shot__link {
  display: block;
}

.guide-shot__link:focus-visible {
  outline: 3px solid var(--purple-deep);
  outline-offset: -3px;
}

.guide-shot__hint {
  display: none;
}

/* Phones: full-screen shots keep a readable size and scroll sideways. */
@media (max-width: 640px) {
  .guide-shot--wide {
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .guide-shot--wide .guide-shot__link {
    width: max-content;
  }

  .guide-shot--wide img {
    width: 640px;
    max-width: none;
  }

  .guide-shot__hint {
    position: sticky;
    left: 0;
    display: block;
    padding: 6px 10px;
    border-top: 1px solid var(--rule-soft);
    background: var(--paper);
    color: rgba(0, 23, 31, 0.72);
    font-family: var(--font-mono);
    font-size: 0.72rem;
  }
}
