/* =====================================================================
   MINOT DIGITAL — ecosystem.css
   Interactive architecture diagram page
   ===================================================================== */

:root {
  --bg-void:     #030810;
  --bg-surface:  #060F1E;
  --bg-elevated: #091525;
  --bg-card:     rgba(6, 15, 30, 0.7);

  --accent:             #0EA5E9;
  --accent-bright:      #38BDF8;
  --accent-dim:         #0369A1;
  --accent-cyan:        #06B6D4;
  --accent-glow:        rgba(14, 165, 233, 0.18);
  --accent-glow-strong: rgba(14, 165, 233, 0.38);

  --text-primary:   #EDF2FF;
  --text-secondary: #7A96B8;
  --text-muted:     #3A526B;

  --border:   rgba(14, 165, 233, 0.11);
  --border-h: rgba(14, 165, 233, 0.28);
  --divider:  rgba(14, 165, 233, 0.08);

  --font-display: 'Syne', 'Georgia', serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Layer colors — one per tier */
  --layer-foundation:  #0EA5E9;
  --layer-identity:    #38BDF8;
  --layer-endpoint:    #06B6D4;
  --layer-productivity:#7DD3FC;
  --layer-comms:       #0284C7;
  --layer-infra:       #0369A1;
  --layer-secauto:     #38BDF8;

  --panel-w: 360px;
}

/* =====================================================================
   RESET
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Film grain */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }

.mono-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
}

/* =====================================================================
   CURSOR GLOW
   ===================================================================== */
.cursor-glow {
  position: fixed;
  pointer-events: none;
  z-index: 9997;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.045) 0%, transparent 65%);
  transform: translate(-50%, -50%);
  will-change: left, top;
  opacity: 0;
  transition: opacity 0.4s ease;
}

@media (hover: none) { .cursor-glow { display: none; } }

/* =====================================================================
   NAV
   ===================================================================== */
.e-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(3, 8, 16, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 2rem;
}

.e-nav-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.e-nav-back {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-secondary);
  transition: color 0.2s;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.e-nav-back:hover { color: var(--accent); border-color: var(--border-h); }

.e-nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  background: var(--accent);
  color: var(--bg-void);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  border-radius: 4px;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
}

.e-nav-hint {
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* =====================================================================
   HERO
   ===================================================================== */
.e-hero {
  padding: 3.5rem 2rem 2.5rem;
  border-bottom: 1px solid var(--divider);
  position: relative;
  overflow: hidden;
  background: var(--bg-surface);
}

.e-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 60% 50%, rgba(14, 165, 233, 0.05), transparent 60%);
  pointer-events: none;
}

.e-hero-inner {
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.e-tag {
  display: inline-block;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.67rem;
  margin-bottom: 0.9rem;
}

.e-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin-bottom: 1rem;
}

.e-title em {
  font-style: normal;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--accent);
  text-stroke: 1.5px var(--accent);
  opacity: 0.75;
}

.e-sub {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 68ch;
  line-height: 1.8;
  margin-bottom: 1.8rem;
}

/* Layer legend */
.e-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.legend-item:hover { background: rgba(255,255,255,0.04); }

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
}

/* =====================================================================
   DIAGRAM WRAPPER
   ===================================================================== */
.e-diagram-wrap {
  padding: 2rem 2rem 4rem;
  max-width: 1600px;
  margin: 0 auto;
  /* Make room for detail panel when open */
  transition: padding-right 0.4s var(--ease-out);
}

.e-diagram-wrap.panel-open {
  padding-right: calc(var(--panel-w) + 2rem);
}

.e-diagram {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* =====================================================================
   CONNECTION SVG
   ===================================================================== */
.conn-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

/* Default connection line */
.conn-line {
  fill: none;
  stroke: rgba(14, 165, 233, 0.1);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  transition: stroke 0.3s, stroke-width 0.3s, stroke-opacity 0.3s;
}

.conn-line.is-active {
  stroke: rgba(14, 165, 233, 0.7);
  stroke-width: 1.5;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 4px rgba(14, 165, 233, 0.4));
}

.conn-line.is-dimmed {
  stroke: rgba(14, 165, 233, 0.04);
}

/* Animated particle on active connection */
.conn-particle {
  fill: var(--accent);
  filter: drop-shadow(0 0 3px var(--accent));
}

/* =====================================================================
   ARCHITECTURE LAYERS
   ===================================================================== */
.arch-layer {
  display: grid;
  grid-template-columns: 180px 1fr;
  border-bottom: 1px solid var(--divider);
  min-height: 130px;
  position: relative;
  z-index: 3;
}

.arch-layer:last-child { border-bottom: none; }

/* Layer label column */
.layer-label-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.25rem 1.25rem 1.25rem 0;
  border-right: 1px solid var(--divider);
  position: relative;
}

.layer-label-col::before {
  content: '';
  position: absolute;
  left: 0;
  top: 1rem;
  bottom: 1rem;
  width: 2px;
  border-radius: 2px;
  background: var(--layer-color, var(--accent));
  box-shadow: 0 0 8px var(--layer-color, var(--accent));
}

.layer-num {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.layer-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  padding-left: 0.75rem;
}

/* Nodes column */
.layer-nodes-col {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1.25rem 1.5rem;
}

/* =====================================================================
   ARCHITECTURE NODES
   ===================================================================== */
.arch-node {
  position: relative;
  padding: 0.9rem 1.1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  min-width: 148px;
  max-width: 200px;
  transition: background 0.25s, border-color 0.25s, transform 0.25s var(--ease-out), box-shadow 0.25s;
  user-select: none;
}

.arch-node:hover {
  background: var(--bg-elevated);
  border-color: var(--border-h);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.arch-node.is-active {
  background: rgba(14, 165, 233, 0.08);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px var(--accent-glow);
  transform: translateY(-2px);
}

.arch-node.is-connected {
  border-color: rgba(14, 165, 233, 0.35);
  background: var(--bg-elevated);
}

.arch-node.is-dimmed {
  opacity: 0.35;
}

/* Node marker dot — color matches layer */
.node-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  margin-bottom: 0.55rem;
  flex-shrink: 0;
  transition: box-shadow 0.3s;
}

.arch-node:hover .node-dot,
.arch-node.is-active .node-dot {
  box-shadow: 0 0 8px var(--nd-color, var(--accent));
}

.node-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 0.2rem;
  color: var(--text-primary);
}

.node-cat {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

/* Active glow effect */
.arch-node.is-active .node-name { color: var(--accent-bright); }

/* =====================================================================
   DETAIL PANEL
   ===================================================================== */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  z-index: 300;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.4s var(--ease-out);
  box-shadow: -20px 0 60px rgba(0,0,0,0.4);
}

.detail-panel.is-open {
  transform: translateX(0);
}

.dp-inner {
  padding: 5rem 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 100%;
}

.dp-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.dp-close:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.dp-tag {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.63rem;
}

.dp-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.dp-layer {
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: -0.75rem;
}

.dp-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.dp-section-label {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.6rem;
  font-weight: 500;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--divider);
}

.dp-what,
.dp-why {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.75;
}

.dp-config {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.dp-config li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.dp-config li::before {
  content: '◆';
  color: var(--accent);
  font-size: 0.45rem;
  flex-shrink: 0;
  margin-top: 0.35em;
}

.dp-connections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.dp-conn-chip {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 0.2rem 0.6rem;
  background: rgba(14, 165, 233, 0.07);
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: 20px;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.dp-conn-chip:hover {
  background: rgba(14, 165, 233, 0.15);
  border-color: var(--accent);
}

.dp-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 16, 0.7);
  z-index: 299;
  backdrop-filter: blur(4px);
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 1200px) {
  :root { --panel-w: 320px; }

  .arch-layer {
    grid-template-columns: 150px 1fr;
  }
}

@media (max-width: 900px) {
  .e-diagram-wrap.panel-open { padding-right: 2rem; }

  .detail-panel {
    width: 100%;
    max-width: 480px;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    height: 70vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .detail-panel.is-open { transform: translateY(0); }
  .dp-backdrop { display: block; }
  .dp-backdrop.is-visible { opacity: 1; pointer-events: auto; }

  .arch-layer {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .layer-label-col {
    border-right: none;
    border-bottom: 1px solid var(--divider);
    padding: 0.75rem 1rem;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }

  .layer-label-col::before {
    position: static;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    top: auto;
    bottom: auto;
    box-shadow: 0 0 6px var(--layer-color, var(--accent));
  }

  .layer-num { display: none; }
  .layer-name { padding-left: 0; font-size: 0.78rem; }

  .layer-nodes-col {
    padding: 0.75rem 1rem 1rem;
    gap: 0.5rem;
  }

  .arch-node { min-width: 120px; padding: 0.7rem 0.9rem; }
  .node-name { font-size: 0.75rem; }

  .e-nav-hint { display: none; }
  .e-diagram-wrap { padding: 1rem 1rem 3rem; }
}

@media (max-width: 600px) {
  .e-hero { padding: 2rem 1.25rem 1.75rem; }
  .e-diagram-wrap { padding: 0.75rem 0.75rem 3rem; }
  .arch-node { min-width: 100px; }
}

/* =====================================================================
   PREFERS REDUCED MOTION
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .conn-svg { display: none; }
  .cursor-glow { display: none; }
}
