/* ============================================================================
   Horizon Engine — Documentation styles
   Layered on top of the shared base stylesheet (../style.css).
   Only docs-specific components live here so the folder stays self-contained
   and works under the horizonengine.horizoncreations.dev subdomain.
   ============================================================================ */

/* ── Docs hero tweaks ──────────────────────────────────────────────────────── */
.he-hero.docs-hero {
  min-height: 62vh;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(200, 134, 26, 0.14), transparent 60%),
    linear-gradient(180deg, #0c0c0c 0%, var(--bg) 100%);
}

.docs-hero .he-hero-content {
  max-width: 900px;
}

.docs-hero .he-hero-sub {
  max-width: 560px;
}

/* ── Docs layout: sticky sidebar + content ─────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 3rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 3.5rem 2rem 5rem;
  align-items: start;
}

.docs-sidebar {
  position: sticky;
  top: 92px;
  align-self: start;
  /* Cap to the viewport below the fixed nav and scroll internally, so a long
     link list never forces the reader to the very bottom of the page to reach
     the lower manual entries. */
  max-height: calc(100vh - 92px - 1.5rem);
  overflow-y: auto;
  /* Room so the last link isn't flush against the scroll edge. */
  padding-bottom: 1rem;
  /* Thin, on-theme scrollbar. */
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dark) transparent;
}

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

.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 4px;
}

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

.docs-sidebar-group {
  margin-bottom: 1.75rem;
}

.docs-sidebar-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.85rem;
  padding-left: 0.9rem;
}

.docs-sidebar-link {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.9rem;
  border-left: 2px solid transparent;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.docs-sidebar-link:hover {
  color: var(--cream);
}

.docs-sidebar-link.active {
  color: var(--gold-light);
  border-left-color: var(--gold);
  background: rgba(200, 134, 26, 0.06);
}

/* ── Docs content column ───────────────────────────────────────────────────── */
.docs-content {
  min-width: 0;
  max-width: 780px;
}

.docs-content > section {
  margin-bottom: 3.25rem;
  scroll-margin-top: 92px;
}

.docs-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.7rem;
}

.docs-content h2 {
  font-size: 1.6rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--cream);
  text-align: left;
  text-transform: none;
  margin-bottom: 0.9rem;
}

.docs-content h3 {
  font-size: 1.12rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--cream);
  margin: 2rem 0 0.75rem;
}

.docs-content p {
  font-size: 0.98rem;
  line-height: 1.8;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.docs-content p a,
.docs-content li a,
.docs-content td a {
  color: var(--gold-light);
  text-decoration: none;
  border-bottom: 1px solid rgba(200, 134, 26, 0.35);
  transition: border-color 0.18s;
}

.docs-content p a:hover,
.docs-content li a:hover,
.docs-content td a:hover {
  border-bottom-color: var(--gold-light);
}

/* Buttons inside docs prose keep their button styling — the inline-link
   rule above would otherwise tint them gold and underline them. */
.docs-content a.primary,
.docs-content a.secondary {
  border-bottom: none;
}

.docs-content a.primary {
  color: #0a0a0a;
}

.docs-content ul,
.docs-content ol {
  margin: 0 0 1.2rem 1.2rem;
  color: var(--text-muted);
}

.docs-content li {
  font-size: 0.98rem;
  line-height: 1.8;
  margin-bottom: 0.4rem;
}

.docs-lead {
  font-size: 1.08rem !important;
  line-height: 1.75 !important;
  color: rgba(240, 232, 216, 0.82) !important;
}

.docs-lead-spaced {
  margin-top: 0.9rem;
}

.docs-figure {
  width: 100%;
  height: auto; /* keep aspect ratio with explicit width/height attributes */
  border-radius: 8px;
  margin: 12px 0 1.5rem;
}

.docs-divider {
  width: 44px;
  height: 1px;
  background: var(--gold-dark);
  margin: 0 0 1.6rem;
}

/* ── Inline code + code blocks ─────────────────────────────────────────────── */
.docs-content code {
  font-family: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
  font-size: 0.85em;
  background: rgba(200, 134, 26, 0.1);
  color: var(--cream);
  padding: 0.12em 0.42em;
  border-radius: 4px;
  border: 1px solid rgba(200, 134, 26, 0.16);
}

.docs-code {
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: #0d1117;
  margin: 0 0 1.5rem;
  transition: border-color 0.25s;
}

.docs-code:hover {
  border-color: var(--border-hover);
}

.docs-code-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #161b22;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.docs-code-title {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-left: 6px;
  letter-spacing: 0.03em;
}

.docs-code pre {
  margin: 0;
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  font-family: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  color: #d7d0c0;
}

.docs-code pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.docs-code .tok-c { color: #6a7382; font-style: italic; } /* comment */
.docs-code .tok-k { color: var(--gold-light); }           /* keyword  */
.docs-code .tok-s { color: #9ecb7e; }                     /* string   */
.docs-code .tok-f { color: #e8d7a8; }                     /* function */
.docs-code .tok-n { color: #c98bcf; }                     /* number   */

/* ── Shader compilation pipeline diagram ───────────────────────────────────── */
.pipeline-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 1.75rem 0 2rem;
  padding: 2.25rem 1.75rem 2rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(200, 134, 26, 0.07), transparent 60%),
    var(--bg-surface);
}

.pipeline-node {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 300px;
  padding: 0.85rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}

.pipeline-node--source {
  border-color: rgba(200, 134, 26, 0.35);
}

.pipeline-node-icon {
  font-size: 1.3rem;
  line-height: 1;
  color: var(--gold);
}

.pipeline-node-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.pipeline-node-label {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--cream);
}

.pipeline-node-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pipeline-arrow {
  position: relative;
  width: 1px;
  height: 30px;
  background: linear-gradient(to bottom, var(--gold-dark), transparent);
}

.pipeline-arrow::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--gold);
}

.pipeline-arrow--fanout {
  height: 34px;
}

.pipeline-chain {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0.15rem 0;
}

.pipeline-chip {
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(200, 134, 26, 0.08);
  color: var(--gold-light);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pipeline-chain-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.pipeline-targets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  width: 100%;
  max-width: 720px;
  margin-top: 0.4rem;
}

.pipeline-target {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  transition: border-color 0.2s, transform 0.2s;
}

.pipeline-target:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
}

.pipeline-target-icon {
  font-size: 1.4rem;
  color: var(--gold);
}

.pipeline-target-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--cream);
}

.pipeline-target-api {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 640px) {
  .pipeline-node {
    min-width: 0;
    width: 100%;
  }

  .pipeline-targets {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Steps ─────────────────────────────────────────────────────────────────── */
.docs-steps {
  list-style: none;
  counter-reset: step;
  margin: 0 0 1.5rem;
  padding: 0;
}

.docs-steps > li {
  position: relative;
  counter-increment: step;
  padding: 0 0 1.75rem 3.4rem;
  margin: 0;
  border-left: 1px solid var(--border);
  margin-left: 1.1rem;
}

.docs-steps > li:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.docs-steps > li::before {
  content: counter(step);
  position: absolute;
  left: -1.1rem;
  top: -0.2rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  color: var(--gold-light);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.docs-steps h3 {
  margin-top: 0 !important;
  font-size: 1rem;
}

.docs-steps p {
  margin-bottom: 0.6rem;
}

/* ── Callouts ──────────────────────────────────────────────────────────────── */
.callout {
  display: flex;
  gap: 0.9rem;
  padding: 1.05rem 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  margin: 0 0 1.5rem;
  border-left-width: 3px;
}

.callout-icon {
  font-size: 1.1rem;
  line-height: 1.6;
  flex-shrink: 0;
}

.callout p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.7;
}

.callout p strong {
  color: var(--cream);
  font-weight: 600;
}

.callout.note    { border-left-color: var(--gold); }
.callout.tip     { border-left-color: #28c840; }
.callout.warning { border-left-color: #febc2e; }

/* ── Feature / topic grid for docs ─────────────────────────────────────────── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin: 0 0 1.5rem;
}

.docs-tile {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.22s, transform 0.22s;
}

.docs-tile:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
}

.docs-tile-icon {
  font-size: 1.4rem;
  color: var(--gold);
  margin-bottom: 0.75rem;
}

.docs-tile h3 {
  margin: 0 0 0.45rem !important;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--cream);
}

.docs-tile p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.docs-tile-more {
  display: inline-block;
  margin-top: 0.9rem;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--gold-light);
}

/* ── Card actions (used on Overview cards — previously unstyled) ───────────── */
.card-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Definition / property table ───────────────────────────────────────────── */
.docs-table-wrap {
  overflow-x: auto;
  margin: 0 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.docs-table th,
.docs-table td {
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}

.docs-table th {
  color: var(--gold);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.74rem;
  background: rgba(200, 134, 26, 0.04);
}

.docs-table td {
  color: var(--text-muted);
  line-height: 1.6;
}

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

.docs-table td code {
  white-space: nowrap;
}

/* ── Prev / Next footer nav ────────────────────────────────────────────────── */
.docs-pager {
  display: flex;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.docs-pager a {
  flex: 1;
  min-width: 0;
  display: block;
  padding: 1.05rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  transition: border-color 0.22s;
}

.docs-pager a:hover {
  border-color: var(--border-hover);
}

.docs-pager .pager-next {
  text-align: right;
}

.docs-pager .pager-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.docs-pager .pager-title {
  display: block;
  font-size: 0.98rem;
  color: var(--gold-light);
}

/* ── Mobile sidebar dropdown toggle (hidden on desktop) ────────────────────── */
.docs-sidebar-toggle {
  display: none;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .docs-layout {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding-top: 1.5rem;
  }

  /* The sidebar becomes a sticky "On this page" bar pinned below the fixed
     70px main nav; tapping it drops the link groups down (docs-nav.js adds
     the button and the .open class). */
  .docs-sidebar {
    position: sticky;
    top: 70px;
    z-index: 40;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0;
    background: rgba(12, 12, 12, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    /* Reset the desktop internal-scroll cap — on mobile the dropdown groups
       scroll themselves and the bar itself must not clip. */
    max-height: none;
    overflow: visible;
  }

  .docs-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.8rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    text-align: left;
  }

  .docs-sidebar-toggle-label {
    flex: 1 1 auto;
    min-width: 0; /* allow the flex item to shrink so the ellipsis kicks in */
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .docs-sidebar-toggle-caret {
    color: var(--gold);
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: transform 0.2s;
  }

  .docs-sidebar.open .docs-sidebar-toggle-caret {
    transform: rotate(180deg);
  }

  .docs-sidebar-groups {
    display: none;
  }

  .docs-sidebar.open .docs-sidebar-groups {
    display: block;
    max-height: min(62vh, 460px);
    overflow-y: auto;
    padding: 0.25rem 0.6rem 1rem;
    border-top: 1px solid var(--border);
  }

  /* Long section names must never widen the dropdown — truncate instead. */
  .docs-sidebar-groups .docs-sidebar-link {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .docs-sidebar-group {
    margin-bottom: 1rem;
  }

  .docs-sidebar-group:first-child {
    margin-top: 0.75rem;
  }

  /* Anchored sections must clear the fixed nav + the sticky bar. */
  .docs-content > section {
    scroll-margin-top: 132px;
  }

  .docs-content {
    max-width: 100%;
  }

  .docs-grid {
    grid-template-columns: 1fr;
  }

  .docs-pager {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .docs-content h2 {
    font-size: 1.35rem;
  }
}
