/* NEXUS Style Guide v2 — cinematic documentation shell */

.nx-guide {
  --nx-content-max: 920px;
  --nx-rail-w: 0px;
  min-height: 100vh;
  padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* Solid void — no quantum weave wallpaper (IR grid = .nx-ir-frame hover only) */
body.nx-guide {
  background-color: var(--nx-surface-page);
  background-image: none;
}
@media (min-width: 900px) {
  .nx-guide { padding-bottom: var(--nx-space-8); }
}
@media (min-width: 1100px) {
  .nx-guide { --nx-rail-w: 8.5rem; }
}

/* Shared content column — hero, main, footer align */
.nx-guide-hero__inner,
.nx-guide-main,
.nx-guide-footer {
  box-sizing: border-box;
  width: 100%;
  max-width: calc(var(--nx-content-max) + var(--nx-rail-w) + var(--nx-pad) * 2);
  margin-inline: auto;
  padding-inline: var(--nx-pad);
  padding-left: calc(var(--nx-rail-w) + var(--nx-pad));
}

/* —— Hero —— */
.nx-guide-hero {
  position: relative;
  min-height: clamp(420px, 72vh, 640px);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.nx-guide-hero__media {
  position: absolute;
  inset: 0;
}
.nx-guide-hero__media .nx-ir-frame {
  position: absolute;
  inset: 0;
}
.nx-guide-hero__media .nx-ir-frame__img {
  object-position: center 30%;
  filter: grayscale(0.1) contrast(1.14) brightness(0.48);
}
.nx-guide-hero__inner {
  position: relative;
  z-index: 2;
  padding-block: var(--nx-space-8);
  /* Dark — photography + smoke type */
  --nx-hero-smoke: #c4bbb3;
  --nx-hero-mist: #8a7f78;
  --nx-hero-matrix: #00c98a;
}
[data-theme="light"] .nx-guide-hero__inner {
  --nx-hero-smoke: var(--nx-text-primary);
  --nx-hero-mist: var(--nx-text-secondary);
  --nx-hero-matrix: var(--nx-matrix);
}
[data-theme="light"] .nx-guide-hero__media {
  display: none;
}
[data-theme="light"] .nx-guide-hero {
  min-height: auto;
  background: var(--nx-surface-page);
}
.nx-guide-hero .nx-eyebrow {
  color: var(--nx-hero-matrix);
}
.nx-guide-hero .nx-display {
  color: var(--nx-hero-smoke);
}
.nx-guide-hero .nx-body,
.nx-guide-hero .nx-body--primary {
  color: var(--nx-hero-mist);
}
.nx-guide-hero__inner::before,
.nx-guide-hero__inner::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(168, 216, 255, 0.4);
  pointer-events: none;
}
.nx-guide-hero__inner::before {
  top: var(--nx-space-4);
  left: calc(var(--nx-rail-w) + var(--nx-pad));
  border-right: none;
  border-bottom: none;
}
.nx-guide-hero__inner::after {
  bottom: var(--nx-space-6);
  right: var(--nx-pad);
  border-left: none;
  border-top: none;
}
/* Hero logo — signal on dark · ink on light */
.nx-logo-hero {
  display: block;
  width: min(100%, 22rem);
  margin: 0 0 var(--nx-space-4);
  line-height: 0;
}
.nx-logo-hero__img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35)) drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
}
[data-theme="light"] .nx-logo-hero__img {
  filter: drop-shadow(0 1px 0 rgba(28, 25, 22, 0.06)) drop-shadow(0 4px 14px rgba(28, 25, 22, 0.08));
}
.nx-logo-hero__img--ink { display: none; }
[data-theme="light"] .nx-logo-hero__img--signal { display: none; }
[data-theme="light"] .nx-logo-hero__img--ink { display: block; }
.nx-guide-hero .nx-display {
  margin: 0 0 var(--nx-space-3);
}
.nx-guide-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--nx-space-4);
  align-items: center;
  margin-top: var(--nx-space-5);
}
/* —— Main content —— */
.nx-guide-main {
  padding-block: var(--nx-space-6);
  position: relative;
  z-index: 1;
  min-width: 0;
}

.nx-section {
  padding-block: var(--nx-space-6);
  scroll-margin-top: calc(var(--nx-bar-h) + var(--nx-space-3));
  position: relative;
}
.nx-section:first-of-type {
  padding-top: 0;
}
.nx-section:last-of-type {
  padding-bottom: 0;
}
.nx-section-head {
  display: flex;
  align-items: baseline;
  gap: var(--nx-space-4);
  margin-bottom: var(--nx-space-4);
}
.nx-section-num {
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-caption);
  color: var(--nx-infrared);
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.nx-section-lead {
  font-size: var(--nx-text-body);
  color: var(--nx-text-secondary);
  max-width: 52ch;
  margin-bottom: var(--nx-space-6);
  line-height: 1.65;
}

/* —— Panels —— */
.nx-panel {
  background: var(--nx-surface-panel);
  border: 1px solid var(--nx-border);
  padding: var(--nx-space-5);
  margin: var(--nx-space-5) 0;
  backdrop-filter: blur(6px);
}

.nx-panel--dark-preview {
  background: #000;
  border-color: rgba(255, 255, 255, 0.08);
  backdrop-filter: none;
}
.nx-panel__label {
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-stamp);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nx-text-muted);
  margin-bottom: var(--nx-space-4);
}

/* —— Grids —— */
.nx-grid-2 {
  display: grid;
  gap: var(--nx-space-5);
  width: 100%;
  min-width: 0;
}
.nx-grid-2 > * {
  min-width: 0;
}
@media (min-width: 700px) {
  .nx-grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.nx-grid-3 {
  display: grid;
  gap: var(--nx-space-4);
  width: 100%;
  min-width: 0;
}
.nx-grid-3 > * {
  min-width: 0;
}
@media (min-width: 600px) {
  .nx-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* —— Rules —— */
.nx-rules {
  display: grid;
  gap: var(--nx-space-5);
}
@media (min-width: 600px) {
  .nx-rules { grid-template-columns: 1fr 1fr; }
}
.nx-rules ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--nx-text-small);
  color: var(--nx-text-secondary);
  line-height: 1.7;
}
.nx-rules li {
  padding: var(--nx-space-1) 0;
}

/* —— Device previews —— */
.nx-device {
  border: 1px solid var(--nx-border);
  background: var(--nx-void);
  overflow: hidden;
  box-shadow: var(--nx-shadow-elevated);
}
.nx-device--desktop {
  aspect-ratio: 16 / 10;
  max-height: 360px;
}
.nx-device--mobile {
  max-width: 280px;
  aspect-ratio: 9 / 19;
  margin: 0 auto;
}
.nx-device__chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--nx-space-2) var(--nx-space-3);
  background: var(--nx-surface-bar);
  border-bottom: 1px solid var(--nx-border);
  font-family: var(--nx-font-mono);
  font-size: 0.48rem;
  letter-spacing: 0.1em;
  color: var(--nx-text-muted);
}
.nx-device__viewport {
  padding: var(--nx-space-4);
  height: calc(100% - 28px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--nx-space-3);
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, transparent 55%),
    url("../assets/pins/threshold-11.jpg") center / cover no-repeat;
}


/* —— Tables —— */
.nx-table-wrap {
  margin: var(--nx-space-4) 0;
  overflow-x: auto;
}
.nx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--nx-text-small);
  margin: 0;
}
.nx-table th,
.nx-table td {
  padding: 0.65rem 0.5rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--nx-border);
}
.nx-table th {
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-stamp);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nx-text-muted);
}
.nx-table tbody tr:last-child td,
.nx-table tbody tr:last-child th {
  border-bottom: none;
}
.nx-table td { color: var(--nx-text-secondary); }
.nx-table code {
  font-family: var(--nx-font-mono);
  font-size: 0.75em;
}
[data-theme="light"] .nx-table-wrap {
  background: var(--nx-surface-table);
  border: 1px solid var(--nx-border-strong);
  border-radius: 0;
}
[data-theme="light"] .nx-table th {
  color: var(--nx-text-muted);
  border-bottom: 2px solid var(--nx-border-strong);
}
[data-theme="light"] .nx-table td {
  color: var(--nx-text-primary);
  border-bottom-color: var(--nx-border);
}
[data-theme="light"] .nx-panel {
  border-color: var(--nx-border-strong);
  box-shadow: var(--nx-shadow-elevated);
}
[data-theme="light"] .nx-snippet {
  border-color: var(--nx-border-strong);
  box-shadow: 0 2px 12px rgba(28, 25, 22, 0.06);
}
[data-theme="light"] .nx-card,
[data-theme="light"] .nx-empty,
[data-theme="light"] .nx-motif-card,
[data-theme="light"] .nx-img-card,
[data-theme="light"] .nx-do-dont__do,
[data-theme="light"] .nx-do-dont__dont {
  border-color: var(--nx-border-strong);
}
[data-theme="light"] .nx-caption,
[data-theme="light"] .nx-section-lead {
  color: var(--nx-text-secondary);
}

/* —— Theme toggle —— */
.nx-theme-toggle {
  display: inline-flex;
  border: 1px solid var(--nx-toggle-border);
  background: var(--nx-toggle-bg);
  color: var(--nx-toggle-idle);
}
.nx-theme-toggle button {
  min-height: var(--nx-touch);
  min-width: 4.25rem;
  padding: 0 1rem;
  border: none;
  background: none;
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-caption);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nx-toggle-idle);
  cursor: pointer;
  transition: color var(--nx-duration), background var(--nx-duration), box-shadow var(--nx-duration);
}
.nx-theme-toggle button:hover:not(.is-active) {
  color: var(--nx-toggle-active);
  background: var(--nx-surface-hover);
}
.nx-theme-toggle button.is-active {
  color: var(--nx-toggle-active);
  background: var(--nx-surface-hover);
  box-shadow: inset 0 -2px 0 var(--nx-link);
}
.nx-theme-toggle button:focus-visible {
  outline: 2px solid var(--nx-focus);
  outline-offset: -2px;
}
.nx-theme-toggle button + button {
  border-left: 1px solid var(--nx-toggle-divider);
}

/* —— Icon color toggle —— */
.nx-icon-toggle {
  display: inline-flex;
  border: 1px solid var(--nx-toggle-border);
  background: var(--nx-toggle-bg);
  color: var(--nx-toggle-idle);
}
.nx-icon-toggle button {
  min-height: var(--nx-touch);
  min-width: 3.5rem;
  padding: 0 0.75rem;
  border: none;
  background: none;
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-caption);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nx-toggle-idle);
  cursor: pointer;
  transition: color var(--nx-duration), background var(--nx-duration), box-shadow var(--nx-duration);
}
.nx-icon-toggle button:hover:not(.is-active) {
  color: var(--nx-toggle-active);
  background: var(--nx-surface-hover);
}
.nx-icon-toggle button.is-active {
  color: var(--nx-toggle-active);
  background: var(--nx-surface-hover);
  box-shadow: inset 0 -2px 0 var(--nx-icon-color);
}
.nx-icon-toggle button:focus-visible {
  outline: 2px solid var(--nx-focus);
  outline-offset: -2px;
}
.nx-icon-toggle button + button {
  border-left: 1px solid var(--nx-toggle-divider);
}

/* —— Footer —— */
.nx-guide-footer {
  padding-block: var(--nx-space-8);
  text-align: center;
  position: relative;
  z-index: 1;
  background: var(--nx-footer-scrim);
}


.nx-skip {
  position: absolute;
  left: -9999px;
  top: var(--nx-space-3);
  z-index: 9999;
  padding: var(--nx-space-3) var(--nx-space-4);
  background: var(--nx-infrared);
  color: var(--nx-signal-text);
  font-family: var(--nx-font-mono);
  text-decoration: none;
}
.nx-skip:focus { left: var(--nx-pad); }

/* —— Bar enhancement —— */
.nx-guide .nx-bar {
  background: var(--nx-surface-bar);
  border-bottom-color: var(--nx-border-accent);
}
/* —— Theme apply —— */
.nx-theme-apply {
  margin: var(--nx-space-5) 0;
}
.nx-snippet {
  margin: var(--nx-space-4) 0;
  border: 1px solid var(--nx-border);
  background: var(--nx-surface-raised);
  max-width: 100%;
  min-width: 0;
}
.nx-snippet__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--nx-space-3);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--nx-border);
  background: var(--nx-surface-snippet-bar);
}

.nx-snippet__label {
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-stamp);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nx-text-muted);
}
.nx-snippet__body {
  max-height: 11rem;
  max-width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.nx-snippet .nx-code {
  margin: 0;
  border: none;
  min-height: 0;
  color: var(--nx-code-fg);
}
.nx-code {
  margin: 0;
  padding: var(--nx-space-4);
  background: var(--nx-surface-code);
  border: 1px solid var(--nx-border);
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-small);
  line-height: 1.7;
  color: var(--nx-code-fg);
  overflow-x: auto;
}
.nx-code code { font-family: inherit; white-space: pre; }

.nx-agent-ref .nx-body {
  max-width: none;
}
.nx-theme-previews {
  display: grid;
  gap: var(--nx-space-4);
  margin-top: var(--nx-space-5);
}
@media (min-width: 600px) {
  .nx-theme-previews { grid-template-columns: 1fr 1fr; }
}
.nx-theme-preview {
  padding: var(--nx-space-4);
  background: var(--nx-surface-page);
  color: var(--nx-text-primary);
  border: 1px solid var(--nx-border);
}
.nx-theme-preview__label {
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-stamp);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nx-text-muted);
  margin-bottom: var(--nx-space-3);
}
.nx-theme-preview .nx-btn--primary {
  margin-top: var(--nx-space-3);
}

/* —— Type specimens —— */
.nx-type-family {
  margin: var(--nx-space-6) 0 var(--nx-space-4);
}
.nx-type-family:first-child { margin-top: 0; }
.nx-type-family__name {
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-caption);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nx-infrared);
  margin-bottom: var(--nx-space-3);
}
.nx-type-row {
  display: grid;
  gap: var(--nx-space-2);
  padding: var(--nx-space-4) 0;
  border-bottom: 1px solid var(--nx-border);
}
.nx-type-row:last-child { border-bottom: none; }
@media (min-width: 700px) {
  .nx-type-row {
    grid-template-columns: 1fr 9rem;
    align-items: baseline;
    gap: var(--nx-space-5);
  }
}
.nx-type-row__sample > * { margin: 0; }
.nx-type-row__meta {
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-stamp);
  color: var(--nx-text-muted);
  line-height: 1.6;
}
.nx-type-row__meta code {
  display: block;
  color: var(--nx-matrix);
  margin-bottom: 0.35rem;
}
/* —— Interaction demos —— */
.nx-ix-ir-demo {
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: 280px;
  border: 1px solid var(--nx-border);
  overflow: hidden;
}
.nx-ix-docs {
  display: grid;
  gap: var(--nx-space-3);
}
.nx-ix-docs dt {
  font-family: var(--nx-font-mono);
  font-size: var(--nx-text-stamp);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nx-phosphor-hi);
}
.nx-ix-docs dd {
  margin: 0 0 var(--nx-space-3);
  font-size: var(--nx-text-small);
  color: var(--nx-text-secondary);
  line-height: 1.55;
}

/* —— Swatch grid polish —— */
.nx-swatch-grid {
  gap: 2px;
}
.nx-swatch {
  transition: transform var(--nx-duration) var(--nx-ease);
}
.nx-swatch:hover {
  transform: translateY(-2px);
  z-index: 1;
}

/* —— Motifs (from v1) —— */
.nx-motif-grid {
  display: grid;
  gap: 3px;
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .nx-motif-grid { grid-template-columns: 1fr 1fr; }
}
.nx-motif-card {
  background: var(--nx-surface-raised);
  border: 1px solid var(--nx-border);
  padding: var(--nx-space-5);
  position: relative;
  min-height: 200px;
}
.nx-motif-card::before,
.nx-motif-card::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(168, 216, 255, 0.35);
  pointer-events: none;
}
.nx-motif-card::before { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.nx-motif-card::after { bottom: 8px; right: 8px; border-left: none; border-top: none; }
.nx-motif-card .nx-tag {
  margin-bottom: var(--nx-space-4);
}
.nx-motif-demo {
  height: 88px;
  margin-bottom: var(--nx-space-4);
  border: 1px solid var(--nx-border);
}
.nx-motif-demo--grid {
  background:
    linear-gradient(rgba(0, 229, 160, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 216, 255, 0.15) 1px, transparent 1px);
  background-size: 16px 16px;
}
.nx-motif-demo--mirror {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
}
.nx-motif-demo--mirror span:first-child {
  font-family: var(--nx-font-display);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 0.28em;
  color: var(--nx-smoke);
}
.nx-motif-demo--mirror span:last-child {
  font-family: var(--nx-font-display);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 0.28em;
  color: var(--nx-smoke);
  opacity: 0.25;
  transform: scaleY(-1);
  margin-top: -0.2rem;
  mask-image: linear-gradient(to bottom, #000, transparent);
}
.nx-motif-demo--ir {
  position: relative;
  background: var(--nx-void);
  display: flex;
  align-items: flex-end;
  padding: var(--nx-space-3);
  overflow: hidden;
}
.nx-motif-demo--ir::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 65% 45%, rgba(255, 76, 0, 0.55), transparent 35%),
    radial-gradient(circle at 30% 60%, rgba(168, 216, 255, 0.15), transparent 40%);
}
.nx-motif-demo--ir span {
  position: relative;
  font-family: var(--nx-font-mono);
  font-size: 0.55rem;
  color: var(--nx-infrared);
  letter-spacing: 0.1em;
}
.nx-motif-demo--pcb {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--nx-phosphor-hi);
  background: var(--nx-surface-code);
}
.nx-motif-demo--pcb svg { width: 88%; height: auto; }
.nx-motif-demo--robot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.nx-motif-target {
  width: 48px;
  height: 48px;
  position: relative;
  border: 1px solid rgba(76, 89, 107, 0.5);
}
.nx-motif-target span {
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1px solid var(--nx-phosphor-hi);
}
.nx-motif-target .tl { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.nx-motif-target .tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
.nx-motif-target .bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }
.nx-motif-target .br { bottom: -1px; right: -1px; border-left: none; border-top: none; }
.nx-motif-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--nx-infrared);
  opacity: 0.7;
  animation: nx-motif-scan 2.5s linear infinite;
}
@keyframes nx-motif-scan {
  0% { top: 10%; }
  100% { top: 90%; }
}

.nx-img-card {
  padding: var(--nx-space-4);
  background: var(--nx-surface-raised);
  border: 1px solid var(--nx-border);
}
.nx-img-card .nx-h3 { margin-bottom: var(--nx-space-2); }

.nx-do-dont {
  display: grid;
  gap: var(--nx-space-4);
}
@media (min-width: 600px) {
  .nx-do-dont { grid-template-columns: 1fr 1fr; }
}
.nx-do-dont__do,
.nx-do-dont__dont {
  padding: var(--nx-space-5);
  background: var(--nx-surface-panel);
  border: 1px solid var(--nx-border);
  backdrop-filter: blur(6px);
}
.nx-theme-preview[data-theme="dark"] {
  background: #141312;
  color: #c4bbb3;
  border-color: rgba(255, 255, 255, 0.08);
}
.nx-theme-preview[data-theme="dark"] .nx-body--primary {
  color: #c4bbb3;
}
.nx-theme-preview .nx-link {
  color: var(--nx-link);
}
.nx-theme-preview .nx-link:hover {
  color: var(--nx-link-hover);
}
.nx-theme-preview[data-theme="light"] {
  background: #e8e2dc;
  color: #1c1916;
  border-color: rgba(28, 25, 22, 0.26);
}
.nx-theme-preview[data-theme="light"] .nx-body--primary {
  color: #1c1916;
}
.nx-theme-preview[data-theme="light"] .nx-theme-preview__label {
  color: #6b635c;
}

@media (prefers-reduced-motion: reduce) {
  .nx-motif-scan { animation: none; }
  .nx-logo-hero__img { filter: none; }
}