/* ============================================================
   How It Works — docs-style reference with left rail + search
   ============================================================ */

.hiw-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 56px;
  margin-top: 8px;
  max-width: 1120px;
  align-items: start;
}

@media (max-width: 1000px) {
  .hiw-shell {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 32px;
  }
}

@media (max-width: 800px) {
  .hiw-shell {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .hiw-rail {
    position: static;
    max-height: none;
  }
}

/* ── Left rail ────────────────────────────────────── */
.hiw-rail {
  position: sticky;
  top: 72px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 4px 8px 24px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.hiw-search-wrap {
  position: relative;
  margin-bottom: 14px;
}

.hiw-search {
  width: 100%;
  height: 32px;
  padding: 0 28px 0 32px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text1);
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.hiw-search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-inset);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.hiw-search::placeholder {
  color: var(--text3);
}

.hiw-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  stroke: var(--text3);
  stroke-width: 1.6;
  fill: none;
  pointer-events: none;
  transition: stroke 0.15s ease;
}

.hiw-search:focus ~ .hiw-search-icon {
  stroke: var(--accent);
}

.hiw-search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.hiw-search-clear:hover {
  color: var(--text1);
  background: var(--panel-inset);
}

.hiw-search-stats {
  font-size: 11px;
  color: var(--text3);
  margin: -4px 0 12px;
  padding: 0 4px;
  letter-spacing: 0.2px;
}

.hiw-search-stats.empty {
  color: var(--amber);
}

.hiw-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: relative;
  padding-left: 1px;
}

.hiw-nav::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--border);
}

.hiw-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  margin-left: -1px;
  border: none;
  border-left: 2px solid transparent;
  background: none;
  color: var(--text2);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 0 6px 6px 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.2s ease;
}

.hiw-nav-item:hover {
  color: var(--text1);
  background: var(--panel-inset);
}

.hiw-nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.hiw-nav-item.dimmed {
  opacity: 0.3;
}

.hiw-nav-item.dimmed:hover {
  opacity: 0.55;
}

.hiw-nav-num {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--text3);
  letter-spacing: 0.5px;
  min-width: 18px;
}

.hiw-nav-item.active .hiw-nav-num {
  color: var(--accent);
}

.hiw-nav-title {
  flex: 1;
  font-weight: 500;
}

.hiw-nav-count {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-family: 'DM Mono', ui-monospace, monospace;
  letter-spacing: 0.3px;
  min-width: 20px;
  text-align: center;
}

/* ── Content column ───────────────────────────────── */
.hiw-content {
  min-width: 0;
  max-width: 740px;
  padding-bottom: 80px;
}

.hiw-section {
  padding: 40px 0 24px;
  scroll-margin-top: 80px;
  border-top: 1px solid var(--border);
}

.hiw-section:first-child {
  border-top: none;
  padding-top: 8px;
}

.hiw-eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.7px;
  color: var(--text3);
  text-transform: uppercase;
}

.hiw-step-num {
  color: var(--accent);
  font-weight: 600;
}

.hiw-step-divider {
  height: 1px;
  width: 24px;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}

.hiw-step-label {
  color: var(--text3);
}

.hiw-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text1);
  margin: 0 0 22px;
  line-height: 1.18;
}

.hiw-body {
  color: var(--text2);
  font-size: 14px;
  line-height: 1.7;
}

.hiw-body h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
  margin: 32px 0 10px;
  letter-spacing: -0.005em;
}

.hiw-body h3:first-child {
  margin-top: 8px;
}

.hiw-body p {
  margin: 0 0 12px;
}

.hiw-body p:last-child {
  margin-bottom: 0;
}

.hiw-body ul,
.hiw-body ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.hiw-body li {
  margin-bottom: 6px;
  padding-left: 2px;
}

.hiw-body li::marker {
  color: var(--text3);
}

.hiw-body strong {
  color: var(--text1);
  font-weight: 600;
}

.hiw-body em {
  color: var(--text1);
  font-style: italic;
}

.hiw-body code {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 12px;
  padding: 1px 5px;
  background: var(--panel-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text1);
}

.hiw-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.hiw-body a:hover {
  border-bottom-color: var(--accent);
}

/* ── Pillars (Overview) ───────────────────────────── */
.hiw-pillars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 22px;
}

.hiw-pillar {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--panel-inset);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.hiw-pillar:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--panel-bg);
  transform: translateY(-1px);
  cursor: pointer;
}

.hiw-pillar-num {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

.hiw-pillar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
  margin-bottom: 3px;
}

.hiw-pillar-blurb {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.45;
}

/* ── Search highlight ─────────────────────────────── */
.hiw-mark {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  color: var(--text1);
  padding: 0 2px;
  margin: 0 -1px;
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ── Empty state ──────────────────────────────────── */
.hiw-empty {
  padding: 60px 0;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

.hiw-empty-title {
  font-size: 15px;
  color: var(--text1);
  font-weight: 600;
  margin-bottom: 6px;
}

/* ── Checklist widget ─────────────────────────────── */
.hiw-checklist {
  list-style: none;
  padding: 0;
  margin: 16px 0 20px;
  counter-reset: hiw-check;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hiw-checklist > li {
  counter-increment: hiw-check;
  position: relative;
  padding: 12px 14px 12px 48px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-inset);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text2);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.hiw-checklist > li::before {
  content: counter(hiw-check, decimal-leading-zero);
  position: absolute;
  left: 14px;
  top: 12px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.hiw-checklist > li strong {
  color: var(--text1);
  font-weight: 600;
}

/* ── Callout widget ───────────────────────────────── */
.hiw-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin: 14px 0;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 5%, var(--panel-inset));
  font-size: 13px;
  line-height: 1.55;
  color: var(--text2);
}

.hiw-callout--tip {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--panel-inset));
}

.hiw-callout--warning {
  border-left-color: var(--amber);
  background: color-mix(in srgb, var(--amber) 7%, var(--panel-inset));
}

.hiw-callout--info {
  border-left-color: var(--text3);
  background: var(--panel-inset);
}

.hiw-callout--note {
  border-left-color: var(--green);
  background: color-mix(in srgb, var(--green) 5%, var(--panel-inset));
}

.hiw-callout-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hiw-callout-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
  fill: none;
  stroke: currentColor;
}

.hiw-callout--tip .hiw-callout-icon { color: var(--accent); }
.hiw-callout--warning .hiw-callout-icon { color: var(--amber); }
.hiw-callout--info .hiw-callout-icon { color: var(--text3); }
.hiw-callout--note .hiw-callout-icon { color: var(--green); }

.hiw-callout-body {
  flex: 1;
  min-width: 0;
}

.hiw-callout-body strong {
  color: var(--text1);
  font-weight: 600;
}

.hiw-callout-body p {
  margin: 0;
}

.hiw-callout-body p + p {
  margin-top: 6px;
}

/* ── FAQ accordion (Glossary section) ─────────────── */
.hiw-faq {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0 20px;
}

.hiw-faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-inset);
  padding: 12px 14px;
}

.hiw-faq-q {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
  margin: 0 0 6px;
}

.hiw-faq-a {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  margin: 0;
}

/* ── Glossary grid ────────────────────────────────── */
.hiw-glossary {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px 16px;
  margin: 16px 0 20px;
  font-size: 13px;
  line-height: 1.55;
}

.hiw-glossary dt {
  font-weight: 600;
  color: var(--text1);
  padding-top: 2px;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 12px;
}

.hiw-glossary dd {
  color: var(--text2);
  margin: 0 0 8px;
}
