/* Horizon 87: Technical build notes (standalone long-form page) */

:root {
  --dl-bg: #070b10;
  --dl-panel: #0c1118;
  --dl-elevated: #121922;
  --dl-line: rgba(255, 255, 255, 0.08);
  --dl-line-strong: rgba(255, 255, 255, 0.12);
  --dl-text: #e8edf3;
  --dl-text-soft: #a8b4c0;
  --dl-text-faint: #6f7d8b;
  --dl-accent: #5ce0cc;
  --dl-accent-dim: rgba(92, 224, 204, 0.12);
  --dl-warn: #f0b86a;
  --dl-font: "IBM Plex Sans", system-ui, -apple-system, Roboto, sans-serif;
  --dl-mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --dl-sidebar: 280px;
  --dl-header: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--dl-header) + 24px);
}

body {
  margin: 0;
  font-family: var(--dl-font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--dl-text);
  background: var(--dl-bg);
}

a {
  color: var(--dl-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--dl-mono);
  font-size: 0.875em;
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #c5f5ec;
}

/* Header */
.dl-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--dl-header);
  padding: 0 20px;
  border-bottom: 1px solid var(--dl-line);
  background: rgba(7, 11, 16, 0.92);
  backdrop-filter: blur(8px);
}

.dl-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dl-header-brand img {
  width: 24px;
  height: 24px;
  border-radius: 5px;
}

.dl-header-brand h1 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dl-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--dl-line-strong);
  border-radius: 8px;
  background: var(--dl-elevated);
  color: var(--dl-text);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: none;
}

.dl-btn:hover {
  border-color: rgba(92, 224, 204, 0.35);
  background: var(--dl-accent-dim);
  text-decoration: none;
}

.dl-btn--accent {
  border-color: rgba(92, 224, 204, 0.4);
  background: var(--dl-accent-dim);
  color: var(--dl-accent);
}

.dl-menu-toggle {
  display: none;
}

/* Layout */
.dl-shell {
  display: grid;
  grid-template-columns: var(--dl-sidebar) minmax(0, 1fr);
  min-height: calc(100vh - var(--dl-header));
}

.dl-sidebar {
  position: sticky;
  top: var(--dl-header);
  align-self: start;
  max-height: calc(100vh - var(--dl-header));
  overflow: auto;
  padding: 20px 0 40px;
  border-right: 1px solid var(--dl-line);
  background: var(--dl-panel);
}

.dl-sidebar-label {
  margin: 0 16px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dl-text-faint);
}

.dl-toc {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dl-toc a {
  display: block;
  padding: 7px 16px 7px 20px;
  border-left: 2px solid transparent;
  color: var(--dl-text-soft);
  font-size: 0.8125rem;
  line-height: 1.35;
  text-decoration: none;
}

.dl-toc a:hover {
  color: var(--dl-text);
  background: rgba(255, 255, 255, 0.03);
  text-decoration: none;
}

.dl-toc a.is-active {
  border-left-color: var(--dl-accent);
  color: var(--dl-accent);
  background: var(--dl-accent-dim);
}

.dl-toc .dl-toc-sub a {
  padding-left: 32px;
  font-size: 0.75rem;
}

.dl-main {
  max-width: 820px;
  padding: 40px 48px 120px;
}

/* Typography */
.dl-kicker {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dl-accent);
}

.dl-chapter {
  margin: 0 0 64px;
  padding-bottom: 64px;
  border-bottom: 1px solid var(--dl-line);
}

.dl-chapter:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.dl-chapter h2 {
  margin: 0 0 20px;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.dl-chapter h3 {
  margin: 36px 0 12px;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--dl-text);
}

.dl-chapter h4 {
  margin: 24px 0 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--dl-text-soft);
}

.dl-chapter p {
  margin: 0 0 16px;
  color: var(--dl-text-soft);
}

.dl-chapter p strong {
  color: var(--dl-text);
  font-weight: 600;
}

.dl-lead {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--dl-text) !important;
}

.dl-meta {
  margin: 0 0 32px;
  font-size: 0.8125rem;
  color: var(--dl-text-faint);
}

/* Blocks */
.dl-plain {
  margin: 24px 0;
  padding: 16px 18px;
  border-left: 3px solid var(--dl-accent);
  border-radius: 0 8px 8px 0;
  background: var(--dl-accent-dim);
}

.dl-plain-label {
  margin: 0 0 8px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dl-accent);
}

.dl-plain p:last-child {
  margin-bottom: 0;
}

.dl-warn {
  border-left-color: var(--dl-warn);
  background: rgba(240, 184, 106, 0.08);
}

.dl-warn .dl-plain-label {
  color: var(--dl-warn);
}

.dl-math,
.dl-code {
  margin: 16px 0 20px;
  padding: 16px 18px;
  overflow-x: auto;
  border: 1px solid var(--dl-line);
  border-radius: 8px;
  background: #060a0f;
  font-family: var(--dl-mono);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: #b8c8d4;
  white-space: pre-wrap;
}

.dl-math .dl-eq {
  display: block;
  margin: 6px 0;
}

.dl-file {
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.8125rem;
  color: var(--dl-text-faint);
}

.dl-file strong {
  color: var(--dl-accent);
  font-family: var(--dl-mono);
  font-weight: 500;
}

.dl-table-wrap {
  overflow-x: auto;
  margin: 20px 0;
}

table.dl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.dl-table th,
.dl-table td {
  padding: 10px 12px;
  border: 1px solid var(--dl-line);
  text-align: left;
  vertical-align: top;
}

.dl-table th {
  background: var(--dl-elevated);
  color: var(--dl-text);
  font-weight: 600;
}

.dl-table td {
  color: var(--dl-text-soft);
}

.dl-table code {
  font-size: 0.8125rem;
}

ul.dl-list,
ol.dl-list {
  margin: 0 0 16px;
  padding-left: 1.25rem;
  color: var(--dl-text-soft);
}

.dl-list li {
  margin-bottom: 8px;
}

.dl-progress {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  padding: 10px 14px;
  border: 1px solid var(--dl-line-strong);
  border-radius: 999px;
  background: rgba(12, 17, 24, 0.94);
  backdrop-filter: blur(6px);
  font-size: 0.75rem;
  color: var(--dl-text-faint);
}

@media (max-width: 960px) {
  .dl-shell {
    grid-template-columns: 1fr;
  }

  .dl-menu-toggle {
    display: inline-flex;
  }

  .dl-sidebar {
    position: fixed;
    top: var(--dl-header);
    left: 0;
    bottom: 0;
    width: min(var(--dl-sidebar), 88vw);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
  }

  .dl-sidebar.is-open {
    transform: translateX(0);
  }

  .dl-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--dl-header) 0 0 0;
    z-index: 80;
    background: rgba(0, 0, 0, 0.5);
  }

  .dl-sidebar-backdrop.is-open {
    display: block;
  }

  .dl-main {
    padding: 28px 20px 100px;
  }
}

@media print {
  .dl-header,
  .dl-sidebar,
  .dl-progress,
  .dl-menu-toggle {
    display: none !important;
  }

  .dl-shell {
    display: block;
  }

  .dl-main {
    max-width: none;
    padding: 0;
  }

  .dl-chapter {
    break-inside: avoid;
  }
}
