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

:root {
  --bg: #eef1f5;
  --bg-alt: #e4e9ef;
  --surface: #ffffff;
  --ink: #33414f;
  --ink-dim: #6b7a89;
  --line: #c7d0da;
  --line-strong: #9fb0c0;
  --accent: #5b7a99;
  --accent-soft: rgba(91, 122, 153, 0.10);
  --leak: #a9695f;
  --leak-soft: rgba(169, 105, 95, 0.10);
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  height: 100%;
  overflow: hidden;
}

/* ── Mobile warning ─────────────────────────────────────────── */
#mobile-msg {
  display: none;
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
@media (max-width: 1099px) { #mobile-msg { display: flex; } }

.mobile-inner { max-width: 420px; }
.mobile-icon { font-size: 3rem; margin-bottom: 1rem; }
.mobile-inner h2 { font-size: 1.6rem; color: var(--accent); margin-bottom: 0.75rem; }
.mobile-inner p { color: var(--ink-dim); line-height: 1.6; }

/* ── Page system ────────────────────────────────────────────── */
.page {
  position: fixed; inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.page.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Title page ─────────────────────────────────────────────── */
#title-page { overflow: hidden; background: var(--bg); }

#title-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}

#title-content {
  position: relative; z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  overflow-y: auto;
  text-align: center;
  padding: 9vh 2rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.title-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
  opacity: 0.85;
}

#title-content h1 {
  font-size: clamp(2.4rem, 4.2vw, 3.8rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 1.1rem;
  color: var(--ink);
  flex-shrink: 0;
}

.accent { color: var(--accent); }

.title-desc {
  max-width: 720px;
  color: var(--ink-dim);
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 1.6rem;
  flex-shrink: 0;
}
.title-desc p + p {
  margin-top: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 2.2rem;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
  flex-shrink: 0;
}
.cta-btn:hover {
  background: var(--accent-soft);
  border-color: var(--ink);
}
.cta-btn .arrow { transition: transform 0.2s; }
.cta-btn:hover .arrow { transform: translateX(4px); }

.sub-btn-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-shrink: 0;
}
.sub-btn {
  padding: 0.5rem 1.2rem;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink-dim);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.sub-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.contact {
  max-width: 720px;
  font-size: 0.78rem;
  color: var(--ink-dim);
  line-height: 1.55;
  flex-shrink: 0;
  /* Pin to the bottom of the title page's flex column */
  margin-top: auto;
  padding-top: 2rem;
}
.contact a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.contact a:hover { text-decoration: underline; }

/* ── Text pages (How to Read / Additional Concerns) ─────────── */
.text-page {
  background: var(--bg);
  overflow-y: auto;
}
.text-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}
.text-back-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-dim);
  padding: 0.35rem 0.9rem;
  font-size: 0.82rem;
  cursor: pointer;
  margin-bottom: 2rem;
  transition: border-color 0.2s, color 0.2s;
}
.text-back-btn:hover { border-color: var(--accent); color: var(--accent); }

.text-inner h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1.4rem;
  letter-spacing: -0.01em;
}
.text-inner p {
  font-size: 0.92rem;
  color: var(--ink-dim);
  line-height: 1.7;
  margin-bottom: 1.1rem;
}
.text-inner ul {
  padding-left: 1.4rem;
}
.text-inner li {
  font-size: 0.92rem;
  color: var(--ink-dim);
  line-height: 1.7;
  margin-bottom: 1rem;
}
.text-inner a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.text-inner a:hover { text-decoration: underline; }

/* ── Pipeline page ──────────────────────────────────────────── */
#pipeline-page {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#pipeline-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1.2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 10;
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 50px;
}

#back-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-dim);
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
}
#back-btn:hover { border-color: var(--accent); color: var(--accent); }

#pipeline-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

#pipeline-wrap {
  flex: 1;
  overflow-y: scroll;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
#pipeline-wrap::-webkit-scrollbar { width: 6px; }
#pipeline-wrap::-webkit-scrollbar-track { background: transparent; }
#pipeline-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

#pipeline-canvas {
  display: block;
}

/* ── Leak side panel ────────────────────────────────────────── */
/* Sits in the otherwise-empty upper-right of the pipeline canvas, revealed
   on hover rather than sliding in — so it should pop in quickly, not slide. */
.side-panel {
  position: fixed;
  top: 65px; right: 20px;
  width: 420px;
  max-height: 600px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem;
  z-index: 100;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
  scrollbar-width: thin;
}
.side-panel.visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.side-panel.hidden { opacity: 0; }

.leak-tag {
  display: inline-block;
  background: var(--leak-soft);
  border: 1px solid rgba(169, 105, 95, 0.35);
  border-radius: 3px;
  color: var(--leak);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  margin-bottom: 0.75rem;
}
/* Blue variant for non-leak panels (stage questions, projects, notes,
   theories of change). */
.leak-tag.tag-info {
  background: var(--accent-soft);
  border-color: rgba(91, 122, 153, 0.35);
  color: var(--accent);
}

.side-panel h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 0.85rem;
}

.leak-text {
  font-size: 0.82rem;
  color: var(--ink-dim);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.leak-hint {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--accent);
  margin-bottom: 0.9rem;
}

.solution-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  color: #5f8a6e;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.solution-header::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  background: #5f8a6e;
  border-radius: 50%;
}

.solution-text { color: #547a63; }

.impact-note {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--ink-dim);
  line-height: 1.5;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.hidden { display: none !important; }
