/**
 * NRDP Reference Terminal theme — scoped to .nrdp-shell
 * Coding-inspired black/white chrome; functional color only in data viz.
 */

.nrdp-shell {
  --nrdp-bg: #0a0a0b;
  --nrdp-bg-elevated: #111113;
  --nrdp-bg-panel: #141416;
  --nrdp-border: #2a2a2e;
  --nrdp-border-subtle: #1f1f23;
  --nrdp-text: #e8e8ea;
  --nrdp-text-secondary: #a1a1aa;
  --nrdp-text-muted: #71717a;
  --nrdp-accent: #22d3ee;
  --nrdp-accent-hover: #67e8f9;
  --nrdp-accent-dim: rgba(34, 211, 238, 0.12);
  --nrdp-accent-ring: rgba(34, 211, 238, 0.35);
  color: var(--nrdp-text);
  font-family: "Source Sans Pro", system-ui, sans-serif;
}

/* Terminal grid background */
.nrdp-shell .nrdp-bg {
  background: var(--nrdp-bg);
  background-image:
    linear-gradient(var(--nrdp-border-subtle) 1px, transparent 1px),
    linear-gradient(90deg, var(--nrdp-border-subtle) 1px, transparent 1px);
  background-size: 24px 24px;
}

.nrdp-shell .nrdp-pattern,
.nrdp-shell .nrdp-starfield {
  opacity: 0 !important;
  display: none;
}

/* Subtle scanline overlay (very light) */
.nrdp-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

.nrdp-shell > .nrdp-content {
  position: relative;
  z-index: 2;
}

/* Typography tokens */
.nrdp-shell .nrdp-text-primary {
  color: var(--nrdp-text);
}
.nrdp-shell .nrdp-text-secondary {
  color: var(--nrdp-text-secondary);
}
.nrdp-shell .nrdp-text-muted {
  color: var(--nrdp-text-muted);
}
.nrdp-shell .nrdp-text-accent {
  color: var(--nrdp-accent);
}

/* Panels (replaces glass cards inside NRDP) */
.nrdp-shell .nrdp-glass-card,
.nrdp-shell .nrdp-panel {
  background: var(--nrdp-bg-panel);
  border: 1px solid var(--nrdp-border);
  border-radius: 0.5rem;
  box-shadow: none;
  backdrop-filter: none;
}

.nrdp-shell .nrdp-glass-card:hover,
.nrdp-shell .nrdp-panel-hover:hover {
  border-color: var(--nrdp-accent-ring);
}

/* Tables */
.nrdp-shell .nrdp-table-wrap {
  background: var(--nrdp-bg-panel);
  border: 1px solid var(--nrdp-border);
  border-radius: 0.5rem;
  backdrop-filter: none;
}

.nrdp-shell .nrdp-table-wrap thead tr {
  background: var(--nrdp-bg-elevated);
}

.nrdp-shell .nrdp-table-wrap tbody tr {
  border-color: var(--nrdp-border-subtle);
}

.nrdp-shell .nrdp-table-wrap tbody tr:hover {
  background: var(--nrdp-accent-dim);
}

/* Inputs */
.nrdp-shell .nrdp-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  background: var(--nrdp-bg-elevated);
  border: 1px solid var(--nrdp-border);
  border-radius: 0.375rem;
  color: var(--nrdp-text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.nrdp-shell .nrdp-input::-moz-placeholder {
  color: var(--nrdp-text-muted);
}

.nrdp-shell .nrdp-input::placeholder {
  color: var(--nrdp-text-muted);
}

.nrdp-shell .nrdp-input:focus {
  border-color: var(--nrdp-accent);
  box-shadow: 0 0 0 2px var(--nrdp-accent-ring);
}

.nrdp-shell select.nrdp-input,
.nrdp-shell .nrdp-select {
  padding-left: 0.75rem;
  cursor: pointer;
}

.nrdp-shell select option {
  background: var(--nrdp-bg-elevated);
  color: var(--nrdp-text);
}

/* Terminal code blocks */
.nrdp-shell .nrdp-code-block {
  background: #0d0d0f;
  border: 1px solid var(--nrdp-border);
  border-radius: 0.375rem;
  padding: 1rem;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--nrdp-text);
  overflow-x: auto;
  white-space: pre;
}

.nrdp-shell .nrdp-code-block .nrdp-code-comment {
  color: var(--nrdp-text-muted);
}

/* Badges */
.nrdp-shell .nrdp-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--nrdp-border);
  border-radius: 0.25rem;
  color: var(--nrdp-text-secondary);
  background: var(--nrdp-bg-elevated);
  font-family: ui-monospace, monospace;
}

.nrdp-shell .nrdp-badge-accent {
  border-color: var(--nrdp-accent-ring);
  color: var(--nrdp-accent);
  background: var(--nrdp-accent-dim);
}

/* NRDP sub-header nav */
.nrdp-subheader {
  background: var(--nrdp-bg-elevated);
  border-bottom: 1px solid var(--nrdp-border);
}

.nrdp-subheader .nrdp-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--nrdp-text-secondary);
  border-radius: 0.25rem;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nrdp-subheader .nrdp-nav-link:hover {
  color: var(--nrdp-text);
  background: rgba(255, 255, 255, 0.04);
}

.nrdp-subheader .nrdp-nav-link-active {
  color: var(--nrdp-accent);
  background: var(--nrdp-accent-dim);
}

.nrdp-wordmark {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.12em;
  color: var(--nrdp-text);
}

.nrdp-wordmark span {
  color: var(--nrdp-accent);
}

/* Hub tool cards */
.nrdp-shell .nrdp-tool-card {
  display: block;
  padding: 1.25rem;
  background: var(--nrdp-bg-panel);
  border: 1px solid var(--nrdp-border);
  border-radius: 0.5rem;
  transition: border-color 0.15s, transform 0.15s;
}

.nrdp-shell .nrdp-tool-card:hover {
  border-color: var(--nrdp-accent);
  transform: translateY(-1px);
}

/* Hub hero — minimal + ambient motion */
.nrdp-hub-hero {
  position: relative;
  border-bottom: 1px solid var(--nrdp-border);
  overflow: hidden;
}

.nrdp-hub-ambient {
  position: absolute;
  inset: -20% -10%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 80% at 15% 40%, rgba(34, 211, 238, 0.07), transparent 55%),
    radial-gradient(ellipse 45% 60% at 85% 60%, rgba(34, 211, 238, 0.04), transparent 50%);
  animation: nrdp-hub-drift 14s ease-in-out infinite alternate;
}

.nrdp-hub-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 5%, rgba(34, 211, 238, 0.35) 50%, transparent 95%);
  animation: nrdp-hub-scan 10s linear infinite;
}

@keyframes nrdp-hub-drift {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(2%, -3%) scale(1.04);
  }
}

@keyframes nrdp-hub-scan {
  0% {
    top: -1px;
    opacity: 0;
  }
  8% {
    opacity: 0.7;
  }
  92% {
    opacity: 0.7;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

.nrdp-hub-inner {
  position: relative;
  z-index: 1;
  max-width: 32rem;
}

.nrdp-hub-enter {
  animation: nrdp-hub-enter 0.55s ease both;
}

.nrdp-hub-enter-1 {
  animation-delay: 0ms;
}
.nrdp-hub-enter-2 {
  animation-delay: 70ms;
}
.nrdp-hub-enter-3 {
  animation-delay: 140ms;
}

@keyframes nrdp-hub-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nrdp-hub-title {
  display: inline-flex;
  align-items: center;
  margin: 0 0 0.5rem;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--nrdp-text);
}

.nrdp-hub-title-mark {
  color: var(--nrdp-accent);
  margin-right: 0.2em;
  animation: nrdp-hub-mark-glow 3.5s ease-in-out infinite;
}

@keyframes nrdp-hub-mark-glow {
  0%,
  100% {
    text-shadow: 0 0 12px rgba(34, 211, 238, 0.15);
  }
  50% {
    text-shadow: 0 0 22px rgba(34, 211, 238, 0.45);
  }
}

.nrdp-hub-cursor {
  display: inline-block;
  width: 0.45em;
  height: 0.85em;
  margin-left: 0.15em;
  background: var(--nrdp-accent);
  animation: nrdp-hub-cursor-blink 1.15s step-end infinite;
}

@keyframes nrdp-hub-cursor-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.nrdp-hub-lede {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--nrdp-text-secondary);
}

.nrdp-hub-search-wrap {
  position: relative;
}

.nrdp-hub-search-wrap:not(:focus-within) .nrdp-hub-search {
  animation: nrdp-hub-search-idle 4s ease-in-out infinite;
}

@keyframes nrdp-hub-search-idle {
  0%,
  100% {
    border-color: var(--nrdp-border);
  }
  50% {
    border-color: rgba(34, 211, 238, 0.35);
  }
}

.nrdp-hub-search {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--nrdp-bg-panel);
  border: 1px solid var(--nrdp-border);
  border-radius: 0.375rem;
  color: var(--nrdp-text);
  font-family: ui-monospace, monospace;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.nrdp-hub-search::-moz-placeholder {
  color: var(--nrdp-text-muted);
  -moz-transition: opacity 0.35s ease;
  transition: opacity 0.35s ease;
}

.nrdp-hub-search::placeholder {
  color: var(--nrdp-text-muted);
  transition: opacity 0.35s ease;
}

.nrdp-hub-search:focus {
  border-color: var(--nrdp-accent);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.2);
  animation: none;
}

.nrdp-hub-search-results {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 50;
  border: 1px solid var(--nrdp-border);
  border-radius: 0.375rem;
  background: var(--nrdp-bg-elevated);
  max-height: 12rem;
  overflow-y: auto;
}

.nrdp-hub-search-hit {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--nrdp-border-subtle);
  color: inherit;
  text-decoration: none;
  transition: background 0.12s;
  animation: nrdp-hub-hit-in 0.25s ease both;
}

@keyframes nrdp-hub-hit-in {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nrdp-hub-ambient,
  .nrdp-hub-scan,
  .nrdp-hub-title-mark,
  .nrdp-hub-cursor,
  .nrdp-hub-enter,
  .nrdp-hub-search-wrap:not(:focus-within) .nrdp-hub-search,
  .nrdp-hub-search-hit {
    animation: none;
  }
}

.nrdp-hub-search-hit:last-child {
  border-bottom: none;
}

.nrdp-hub-search-hit:hover {
  background: var(--nrdp-accent-dim);
}

.nrdp-hub-search-hit-label {
  font-size: 0.8125rem;
  color: var(--nrdp-text);
}

.nrdp-hub-search-hit-meta {
  font-family: ui-monospace, monospace;
  font-size: 0.6875rem;
  color: var(--nrdp-text-muted);
}

/* Tabs (materials) */
.nrdp-shell .nrdp-tab {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--nrdp-text-muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nrdp-shell .nrdp-tab:hover {
  color: var(--nrdp-text-secondary);
}

.nrdp-shell .nrdp-tab-active {
  color: var(--nrdp-accent);
  border-bottom-color: var(--nrdp-accent);
}

/* Breadcrumb */
.nrdp-shell .nrdp-breadcrumb {
  font-size: 0.8125rem;
  font-family: ui-monospace, monospace;
  color: var(--nrdp-text-muted);
}

.nrdp-shell .nrdp-breadcrumb a {
  color: var(--nrdp-text-secondary);
}

.nrdp-shell .nrdp-breadcrumb a:hover {
  color: var(--nrdp-accent);
}

.nrdp-shell .nrdp-breadcrumb-sep {
  margin: 0 0.375rem;
  opacity: 0.5;
}

/* Override site main bg when NRDP */
main.nrdp-main {
  background: var(--nrdp-bg, #0a0a0b) !important;
}

/* Force dark shadcn tokens inside NRDP regardless of the site light/dark toggle,
   so Selects/Tables/Inputs stay readable on the terminal background.
   `.nrdp-shell` (which also carries the `dark` class) is included so these
   terminal values beat the generic `.dark { … }` tokens from index.css. */
main.nrdp-main,
.dark main.nrdp-main,
.nrdp-shell,
.nrdp-shell.dark {
  --background: 240 4% 4%;
  --foreground: 240 5% 91%;
  --card: 240 3% 8%;
  --card-foreground: 240 5% 91%;
  --popover: 240 3% 8%;
  --popover-foreground: 240 5% 91%;
  --muted: 240 4% 12%;
  --muted-foreground: 240 4% 65%;
  --accent: 240 4% 14%;
  --accent-foreground: 240 5% 91%;
  --secondary: 240 4% 12%;
  --secondary-foreground: 240 5% 91%;
  --border: 240 4% 17%;
  --input: 240 4% 12%;
  --ring: 187 92% 53%;
}

main.nrdp-main select option,
.dark main.nrdp-main select option {
  background: #111113;
  color: #e8e8ea;
}

/* Reclaim table styling from index.css's global `.dark table { … !important }`
   remaps so NRDP tables keep the terminal palette. Cell text color is left to
   the nrdp-text-* classes on the cells themselves. */
.nrdp-shell table,
.nrdp-shell table tbody {
  background-color: transparent !important;
  border-color: var(--nrdp-border) !important;
}

.nrdp-shell table th {
  background-color: var(--nrdp-bg-elevated) !important;
  color: var(--nrdp-text-secondary) !important;
  border-color: var(--nrdp-border) !important;
}

.nrdp-shell table td {
  border-color: var(--nrdp-border-subtle) !important;
}

/* index.css's `.dark table td { color … !important }` would flatten the
   text hierarchy — reclaim the nrdp-text-* classes on table cells. */
.nrdp-shell table td.nrdp-text-primary,
.nrdp-shell table th.nrdp-text-primary {
  color: var(--nrdp-text) !important;
}
.nrdp-shell table td.nrdp-text-secondary,
.nrdp-shell table th.nrdp-text-secondary {
  color: var(--nrdp-text-secondary) !important;
}
.nrdp-shell table td.nrdp-text-muted,
.nrdp-shell table th.nrdp-text-muted {
  color: var(--nrdp-text-muted) !important;
}
.nrdp-shell table td.nrdp-text-accent,
.nrdp-shell table th.nrdp-text-accent {
  color: var(--nrdp-accent) !important;
}

/* uPlot chrome on the terminal background (legend text + axis splines) */
.nrdp-shell .u-legend {
  color: var(--nrdp-text-secondary);
}

.nrdp-shell .u-legend .u-value {
  color: var(--nrdp-text);
}

.nrdp-shell .u-select {
  background: var(--nrdp-accent-dim);
}

/* Fullscreen plot panel (Fullscreen API + class-based fallback) */
.nrdp-shell .nrdp-fs-panel:fullscreen {
  background: var(--nrdp-bg);
  padding: 1rem;
  overflow: auto;
}

.nrdp-shell .nrdp-fs-panel.nrdp-fs-fallback {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--nrdp-bg);
  border-radius: 0;
  padding: 1rem;
  overflow: auto;
}

/* Header when on NRDP routes */
header.nrdp-site-header {
  background: #0a0a0b !important;
  border-color: #2a2a2e !important;
  box-shadow: none !important;
}

header.nrdp-site-header .nrdp-header-link {
  color: #e8e8ea;
}

header.nrdp-site-header .nrdp-header-muted {
  color: #52525b;
}

/* Site header nav items on NRDP routes (light or dark site theme) */
header.nrdp-site-header .nav-item-inactive,
.dark header.nrdp-site-header .nav-item-inactive {
  color: #a1a1aa;
}

header.nrdp-site-header .nav-item-inactive:hover,
.dark header.nrdp-site-header .nav-item-inactive:hover {
  color: #e8e8ea;
  background: rgba(255, 255, 255, 0.06);
}

header.nrdp-site-header .nav-item-active,
.dark header.nrdp-site-header .nav-item-active {
  background: rgba(34, 211, 238, 0.12);
  color: #22d3ee;
}

/* Reactor database — full-width spreadsheet */
.nrdp-reactor-sheet-section {
  border-top: 1px solid var(--nrdp-border);
  margin-top: 1.5rem;
  padding-bottom: 2.5rem;
}

.nrdp-reactor-sheet-inner {
  padding-inline: 0.75rem;
}

@media (min-width: 640px) {
  .nrdp-reactor-sheet-inner {
    padding-inline: 1.25rem;
  }
}

@media (min-width: 1024px) {
  .nrdp-reactor-sheet-inner {
    padding-inline: 1.75rem;
  }
}

.nrdp-reactor-sheet-header {
  padding: 1.25rem 0 0.75rem;
}

.nrdp-reactor-sheet-footnote {
  margin-top: 0.75rem;
  max-width: 48rem;
}

.nrdp-reactor-sheet-scroll {
  max-height: min(72vh, calc(100dvh - 9.5rem));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--nrdp-border);
  border-radius: 0.375rem;
  background: var(--nrdp-bg-panel);
  scrollbar-gutter: stable;
}

.nrdp-reactor-sheet {
  width: 100%;
  min-width: -moz-max-content;
  min-width: max-content;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.nrdp-reactor-sheet th,
.nrdp-reactor-sheet td {
  border-right: 1px solid var(--nrdp-border-subtle);
  border-bottom: 1px solid var(--nrdp-border-subtle);
  padding: 0.35rem 0.55rem;
  vertical-align: middle;
  white-space: nowrap;
  background: var(--nrdp-bg-panel);
  color: var(--nrdp-text-secondary);
}

.nrdp-reactor-sheet th:last-child,
.nrdp-reactor-sheet td:last-child {
  border-right: none;
}

.nrdp-reactor-sheet tbody tr:last-child td {
  border-bottom: none;
}

.nrdp-reactor-sheet thead th {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--nrdp-bg-elevated);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--nrdp-text-muted);
  box-shadow: 0 1px 0 var(--nrdp-border-subtle);
  vertical-align: bottom;
}

.nrdp-reactor-sheet tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--nrdp-bg-elevated) 55%, var(--nrdp-bg-panel));
}

.nrdp-reactor-sheet tbody tr:hover td {
  background: var(--nrdp-accent-dim);
}

.nrdp-reactor-sheet .sheet-sticky-left,
.nrdp-reactor-sheet .sheet-sticky-left-2,
.nrdp-reactor-sheet .sheet-sticky-left-3 {
  position: sticky;
  z-index: 20;
}

.nrdp-reactor-sheet thead .sheet-sticky-left,
.nrdp-reactor-sheet thead .sheet-sticky-left-2,
.nrdp-reactor-sheet thead .sheet-sticky-left-3 {
  z-index: 50;
  background: var(--nrdp-bg-elevated);
}

.nrdp-reactor-sheet .sheet-col-idx {
  width: 2rem;
  min-width: 2rem;
  max-width: 2rem;
}

.nrdp-reactor-sheet .sheet-col-match {
  width: 3rem;
  min-width: 3rem;
  max-width: 3rem;
}

.nrdp-reactor-sheet .sheet-col-name {
  min-width: 8.5rem;
}

.nrdp-reactor-sheet .sheet-sticky-left {
  left: 0;
  box-shadow: 1px 0 0 var(--nrdp-border-subtle);
}

.nrdp-reactor-sheet .sheet-sticky-left-2 {
  left: 2rem;
  box-shadow: 1px 0 0 var(--nrdp-border-subtle);
}

.nrdp-reactor-sheet[data-scoring="true"] .sheet-sticky-left-3 {
  left: 5rem;
  box-shadow: 1px 0 0 var(--nrdp-border-subtle);
}

.nrdp-reactor-sheet .cell-num {
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
}

.nrdp-reactor-sheet thead th.sheet-col-head {
  font-size: 0.6875rem;
  font-family: inherit;
}

.nrdp-reactor-sheet .cell-name {
  font-weight: 600;
  color: var(--nrdp-text);
}

.nrdp-reactor-sheet .cell-muted {
  color: var(--nrdp-text-muted);
}

.nrdp-reactor-sheet .cell-text {
  white-space: normal;
  min-width: 5rem;
  max-width: 9rem;
}

.nrdp-reactor-sheet .cell-notes {
  white-space: normal;
  min-width: 8rem;
  max-width: 14rem;
  color: var(--nrdp-text-muted);
  font-size: 0.75rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nrdp-reactor-sheet .sheet-link {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--nrdp-text-accent);
  font-size: 0.75rem;
}

.nrdp-reactor-sheet .sheet-link:hover {
  opacity: 0.85;
}

.nrdp-reactor-sheet tbody tr.nrdp-reactor-row:target td {
  background: rgb(34 211 238 / 0.1);
  box-shadow: inset 0 0 0 1px rgb(34 211 238 / 0.4);
}

.dark .nrdp-reactor-sheet tbody tr.nrdp-reactor-row:target td {
  background: rgb(34 211 238 / 0.14);
}
