/* ============================================================
   NOAH WIRE — Docs Page Styles
   Extends the main design system (style.css) with docs-specific
   layout, sidebar, and content component styles.
   ============================================================ */

/* --- Docs Hero --- */
.docs-hero {
  padding: calc(var(--nav-height) + 4rem) 0 3.5rem;
  background: var(--gradient-hero);
  border-bottom: 1px solid var(--border);
}

.docs-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0.5rem 0 1rem;
  color: var(--text-primary);
}

.docs-hero h1 em {
  font-style: italic;
  color: var(--accent-light);
}

/* --- Docs Layout (two-column) --- */
.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0;
  min-height: 80vh;
  align-items: start;
}

@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
}

/* --- Sidebar --- */
.docs-sidebar {
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.docs-sidebar::-webkit-scrollbar {
  width: 4px;
}

.docs-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.docs-sidebar__inner {
  padding: 1.5rem 0 3rem;
}

@media (max-width: 900px) {
  .docs-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .docs-sidebar__inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    padding: 1rem 1rem;
  }

  .docs-nav-group {
    min-width: 160px;
  }
}

/* --- Sidebar Nav Groups --- */
.docs-nav-group {
  margin-bottom: 0.25rem;
}

.docs-nav-group__label {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 1rem 1.25rem 0.375rem;
  margin-top: 0.25rem;
}

.docs-nav-link {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.3125rem 1.25rem;
  border-left: 2px solid transparent;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
  line-height: 1.4;
}

.docs-nav-link:hover {
  color: var(--text-primary);
  background: var(--accent-subtle);
}

.docs-nav-link.active {
  color: var(--accent-light);
  border-left-color: var(--accent);
  background: var(--accent-subtle);
}

/* --- Main Content --- */
.docs-content {
  padding: 2.5rem 3rem 5rem;
  max-width: 800px;
}

@media (max-width: 1100px) {
  .docs-content {
    padding: 2rem 1.75rem 4rem;
  }
}

@media (max-width: 900px) {
  .docs-content {
    padding: 1.5rem 1.25rem 3rem;
    max-width: 100%;
  }
}

/* --- Part Banner --- */
.docs-part-banner {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.25rem 0 1rem;
  margin: 2.5rem 0 0;
  border-bottom: 1px solid var(--border-accent);
}

.docs-part-banner:first-child {
  margin-top: 0;
}

.docs-part-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
  padding: 0.25rem 0.625rem;
  border-radius: 4px;
  white-space: nowrap;
}

.docs-part-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Section --- */
.docs-section {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border);
}

.docs-section:last-child {
  border-bottom: none;
}

.docs-section h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.875rem;
  scroll-margin-top: calc(var(--nav-height) + 1.5rem);
}

.docs-section h3 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin: 1.5rem 0 0.625rem;
  letter-spacing: 0.01em;
}

.docs-section p {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 1rem;
}

.docs-section p:last-child {
  margin-bottom: 0;
}

.docs-section strong {
  color: var(--text-primary);
  font-weight: 600;
}

.docs-section em {
  color: var(--accent-light);
  font-style: italic;
}

/* Anchor offset for sticky nav */
.docs-section[id] {
  scroll-margin-top: calc(var(--nav-height) + 1.5rem);
}

/* --- Tables --- */
.docs-table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--bg-card);
}

.docs-table th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 0.625rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.docs-table td {
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
  vertical-align: top;
}

.docs-table tr:last-child td {
  border-bottom: none;
}

.docs-table tr:hover td {
  background: var(--bg-card-hover);
}

.docs-table td strong {
  color: var(--text-primary);
}

.docs-table td code,
.docs-table td .docs-code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent-light);
  background: var(--accent-subtle);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* --- Callout Boxes --- */
.docs-callout {
  display: flex;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  border: 1px solid;
  margin: 1.25rem 0;
  font-size: var(--text-sm);
  line-height: 1.65;
}

.docs-callout > div:last-child {
  color: inherit;
  flex: 1;
}

.docs-callout__icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 0.1em;
}

.docs-callout--info {
  background: rgba(13, 148, 136, 0.06);
  border-color: rgba(13, 148, 136, 0.25);
  color: #5eead4;
}

.docs-callout--info .docs-callout__icon {
  color: var(--accent-light);
}

.docs-callout--tip {
  background: rgba(34, 197, 94, 0.06);
  border-color: rgba(34, 197, 94, 0.25);
  color: #86efac;
}

.docs-callout--tip .docs-callout__icon {
  color: #4ade80;
}

.docs-callout--warning {
  background: rgba(234, 179, 8, 0.06);
  border-color: rgba(234, 179, 8, 0.25);
  color: #fde68a;
}

.docs-callout--warning .docs-callout__icon {
  color: #fbbf24;
}

.docs-callout--danger {
  background: rgba(239, 68, 68, 0.07);
  border-color: rgba(239, 68, 68, 0.28);
  color: #fca5a5;
}

.docs-callout--danger .docs-callout__icon {
  color: #f87171;
}

.docs-callout strong {
  color: inherit;
  font-weight: 600;
}

/* --- Screenshots --- */
.docs-screenshot {
  margin: 1.5rem 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: var(--bg-tertiary);
}

.docs-screenshot img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px 10px 0 0;
}

.docs-screenshot__caption {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  padding: 0.625rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
  margin: 0;
  line-height: 1.5;
}

/* --- Data Hierarchy --- */
.docs-hierarchy {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.docs-hierarchy__level {
  padding: 0.3125rem 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.docs-hierarchy__level--0 {
  color: var(--text-primary);
  font-weight: 600;
}

.docs-hierarchy__level--1 {
  padding-left: 1.5rem;
  color: var(--accent-light);
}

.docs-hierarchy__level--2 {
  padding-left: 3rem;
  color: var(--text-secondary);
}

.docs-hierarchy__level--3 {
  padding-left: 4.5rem;
  color: var(--text-tertiary);
}

/* --- Mistake / Bad Practice Boxes --- */
.docs-mistake {
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-left: 3px solid #ef4444;
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: var(--text-sm);
  color: #fca5a5;
}

.docs-mistake strong {
  color: #f87171;
  display: block;
  margin-bottom: 0.375rem;
}

/* --- Steps / How-to Lists --- */
.docs-steps {
  counter-reset: docs-step;
  margin: 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.docs-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.65;
  counter-increment: docs-step;
  position: relative;
}

.docs-step::before {
  content: counter(docs-step);
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-light);
  line-height: 1;
}

/* --- Risk Tags --- */
.docs-risk {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.docs-risk--none {
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.docs-risk--low {
  background: rgba(234, 179, 8, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.2);
}

.docs-risk--medium {
  background: rgba(249, 115, 22, 0.1);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.2);
}

.docs-risk--high {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* --- Cost Cells --- */
.docs-cost {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent-light) !important;
  font-weight: 600;
  white-space: nowrap;
}

/* --- Inline Tags --- */
.docs-tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 0.1em 0.45em;
  border-radius: 3px;
  font-family: var(--font-body);
  font-style: normal;
  vertical-align: middle;
  line-height: 1.6;
}

/* --- Inline Code --- */
.docs-code,
code.docs-code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent-light);
  background: var(--accent-subtle);
  padding: 0.15em 0.45em;
  border-radius: 3px;
  word-break: break-all;
}

/* --- Docs Lists --- */
.docs-list {
  padding-left: 1.375rem;
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.docs-list li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.65;
}

.docs-list li strong {
  color: var(--text-primary);
}

/* --- Example Grid (Good / Bad) --- */
.docs-example-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.25rem 0;
}

@media (max-width: 650px) {
  .docs-example-grid {
    grid-template-columns: 1fr;
  }
}

.docs-example {
  border-radius: 8px;
  border: 1px solid;
  padding: 1rem 1.125rem;
  font-size: var(--text-sm);
  line-height: 1.65;
}

.docs-example__label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.docs-example--good {
  background: rgba(34, 197, 94, 0.05);
  border-color: rgba(34, 197, 94, 0.2);
  color: #bbf7d0;
}

.docs-example--good .docs-example__label {
  color: #4ade80;
}

.docs-example--bad {
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.2);
  color: #fecaca;
}

.docs-example--bad .docs-example__label {
  color: #f87171;
}

.docs-example p,
.docs-example ul,
.docs-example li {
  color: inherit;
  font-size: inherit;
}

.docs-example ul {
  padding-left: 1.25rem;
  margin: 0;
}

.docs-example li {
  margin-bottom: 0.25rem;
}

/* --- Glossary --- */
.docs-glossary {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 1.25rem 0;
}

.docs-glossary__row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.docs-glossary__row:last-child {
  border-bottom: none;
}

.docs-glossary__row:hover {
  background: var(--bg-card-hover);
}

.docs-glossary__term {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-right: 1px solid var(--border);
}

.docs-glossary__def {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: 0.75rem 1rem;
  line-height: 1.6;
}

@media (max-width: 600px) {
  .docs-glossary__row {
    grid-template-columns: 1fr;
  }

  .docs-glossary__term {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.375rem;
  }
}

/* --- URL Map (Appendix A) --- */
.docs-url-table .docs-code {
  font-size: 0.75rem;
  word-break: break-all;
}

/* --- Cost Summary table --- */
.docs-cost-total {
  font-weight: 700;
  color: var(--text-primary) !important;
  background: var(--bg-tertiary);
}

/* --- Section scroll-margin override (all anchor targets) --- */
[id] {
  scroll-margin-top: calc(var(--nav-height) + 1rem);
}
