/* ==========================================================
   nslabs — System Structure / Hierarchy Section
   Pure CSS. No frameworks.
   ========================================================== */

:root {
  --bg-deep: #0a0e1a;
  --bg-surface: #111728;
  --bg-elevated: #161d33;
  --bg-elevated-2: #1a2342;

  --accent: #4f7df5;
  --accent-2: #22d3a7;
  --accent-glow: rgba(79, 125, 245, 0.35);

  --text-primary: #e8ecf4;
  --text-secondary: #8a93ad;
  --text-dim: #5b6480;

  --border: rgba(140, 160, 220, 0.10);
  --border-strong: rgba(140, 160, 220, 0.18);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 0 1px rgba(79, 125, 245, 0.35), 0 8px 28px rgba(79, 125, 245, 0.25);

  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* ===== SECTION SHELL ===== */
.system-hierarchy {
  position: relative;
  padding: 120px 24px;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(79, 125, 245, 0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(34, 211, 167, 0.06), transparent 60%),
    var(--bg-deep);
  overflow: hidden;
}

/* subtle grid */
.system-hierarchy::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  opacity: 0.45;
  pointer-events: none;
}

.hier-container {
  position: relative;
  max-width: 1240px;
  margin: 0 auto;
}

/* ===== HEADER ===== */
.hier-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 80px;
}

.hier-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 22px;
}
.hier-badge .dot {
  width: 6px; height: 6px;
  background: var(--accent-2);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent-2);
}

.hier-header h2 {
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  line-height: 1.05;
}
.hier-header h2 .grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hier-header p {
  max-width: 560px;
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.55;
  margin: 0;
}

/* ===== FLOW (vertical spine on desktop, animated) ===== */
.hier-flow {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  padding-left: 60px;
}

/* Spine line */
.hier-flow::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    var(--accent) 12%,
    var(--accent-2) 88%,
    transparent 100%
  );
  opacity: 0.55;
  border-radius: 2px;
}

/* Pulse traveling down the spine */
.hier-flow::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 0;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 22px var(--accent), 0 0 4px #fff;
  animation: spinePulse 5s ease-in-out infinite;
}

@keyframes spinePulse {
  0%   { transform: translateY(0);    opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(calc(100% + 720px)); opacity: 0; }
}

/* ===== LAYER CARD ===== */
.layer {
  position: relative;
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 36px 30px;
  box-shadow: var(--shadow-lg);
  transition: transform 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
  overflow: hidden;
}

/* Node bullet on the spine */
.layer::before {
  content: "";
  position: absolute;
  left: -44px;
  top: 38px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg-deep);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 125, 245, 0.12);
  z-index: 2;
}

/* Connector from spine to card */
.layer::after {
  content: "";
  position: absolute;
  left: -28px;
  top: 47px;
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.6;
}

.layer:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-glow);
}

/* glow accent inside card */
.layer .glow {
  position: absolute;
  top: -80px;
  right: -80px;
  width: 260px; height: 260px;
  background: radial-gradient(circle, var(--accent-glow), transparent 65%);
  filter: blur(20px);
  pointer-events: none;
  opacity: 0.5;
}

/* ===== LAYER HEAD ===== */
.layer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--border-strong);
}

.layer-id {
  display: flex;
  align-items: center;
  gap: 14px;
}

.layer-num {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.layer-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.layer-title .accent { color: var(--accent); }
.layer-title .accent-2 { color: var(--accent-2); }

.layer-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: rgba(79, 125, 245, 0.10);
  border: 1px solid rgba(79, 125, 245, 0.28);
  color: #b9cbff;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.layer.system .layer-tag {
  background: rgba(34, 211, 167, 0.10);
  border-color: rgba(34, 211, 167, 0.30);
  color: #9ff0d3;
}
.layer.user .layer-tag {
  background: rgba(232, 236, 244, 0.05);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

/* ===== LAYER BODY ===== */
.layer-desc {
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0 0 22px;
  max-width: 640px;
}

.layer-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.layer-list li {
  position: relative;
  padding: 14px 14px 14px 38px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  color: var(--text-primary);
  transition: border-color 0.3s ease, background 0.3s ease;
}

.layer-list li::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), rgba(79, 125, 245, 0.3));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.layer.system .layer-list li::before {
  background: linear-gradient(135deg, var(--accent-2), rgba(34, 211, 167, 0.3));
}
.layer.user .layer-list li::before {
  background: linear-gradient(135deg, #8a93ad, rgba(138, 147, 173, 0.3));
}

.layer-list li:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
}

/* ===== FOOTER STRIP ===== */
.layer-meta {
  display: flex;
  gap: 22px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.layer-meta span b {
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 6px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 760px) {
  .system-hierarchy { padding: 80px 18px; }
  .hier-flow { padding-left: 36px; }
  .hier-flow::before { left: 12px; }
  .hier-flow::after  { left: 6px; }
  .layer { padding: 24px 20px; }
  .layer::before { left: -30px; top: 30px; width: 14px; height: 14px; }
  .layer::after  { left: -16px; top: 37px; width: 16px; }
  .layer-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .layer-list { grid-template-columns: 1fr; }
  .layer-meta { flex-wrap: wrap; gap: 12px; }
}