/* === Tokens === */
:root {
  --bg: #07090d;
  --bg-soft: #0e131a;
  --fg: #e6edf3;
  --fg-dim: #7d8590;
  --rule: #1a2230;
  --blue: #58a6ff;
  --cyan: #5eead4;
  --cursor: #5eead4;
  --node-mol: rgba(94,234,212,0.55);
  --node-pipe: rgba(88,166,255,0.75);
  --node-agent: #9ecbff;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* === Layer stack === */
.pl-canvas, .pl-grid, .pl-sweep, .pl-corners, .pl-scanlines, .pl-vignette, .pl-grain {
  position: fixed; inset: 0; pointer-events: none;
}
.pl-canvas    { z-index: 1; }
.pl-grid      { z-index: 2; }
.pl-sweep     { z-index: 3; }
.pl-corners   { z-index: 4; }
.pl-scanlines { z-index: 5; mix-blend-mode: overlay; }
.pl-vignette  { z-index: 6; }
.pl-grain     { z-index: 7; opacity: 0.01; }
main.pl-main  { position: relative; z-index: 10; }

/* === Dual grid === */
.pl-grid {
  background-image:
    linear-gradient(to right, rgba(94,234,212,0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(94,234,212,0.06) 1px, transparent 1px),
    linear-gradient(to right, rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
}

/* === Sweep === */
.pl-sweep::before {
  content: ""; position: absolute; left: 0; right: 0; height: 1px;
  background: rgba(94,234,212,0.18);
  box-shadow: 0 0 8px rgba(94,234,212,0.35);
  animation: pl-sweep 14s linear infinite;
}
@keyframes pl-sweep {
  0%   { transform: translateY(-2vh); }
  100% { transform: translateY(102vh); }
}

/* === Corner brackets === */
.pl-corners span {
  position: absolute; font-family: var(--font-mono);
  color: rgba(94,234,212,0.4); font-size: 18px;
}
.pl-corners .tl { top: 10px; left: 12px; }
.pl-corners .tr { top: 10px; right: 12px; }
.pl-corners .bl { bottom: 8px; left: 12px; }
.pl-corners .br { bottom: 8px; right: 12px; }

/* === Scanlines === */
.pl-scanlines {
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.03) 0px,
    rgba(255,255,255,0.03) 1px,
    transparent 1px,
    transparent 2px
  );
  animation: pl-flicker 8s ease-in-out infinite;
}
@keyframes pl-flicker {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.85; }
}

/* === Vignette === */
.pl-vignette {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.65) 100%);
}

/* === Grain === */
.pl-grain { background-size: 256px 256px; }

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  .pl-sweep::before, .pl-scanlines { animation: none; }
  .pl-sweep::before { display: none; }
}

/* === Foreground column === */
main.pl-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5rem 1.5rem 4rem;
}
.pl-stage {
  width: 100%;
  max-width: 720px;
  position: relative;
}

/* === Status chip === */
.pl-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  margin: 0 0 2rem;
  opacity: 0;
  animation: pl-fade 0.6s 1.2s ease-out forwards;
}
.pl-status .dot { color: var(--cyan); }
.pl-status .arrow { color: var(--cyan); margin-right: 0.4rem; }

/* === Logo === */
.pl-logo {
  margin-bottom: 3rem;
  position: relative;
  height: 140px;
}
.pl-logo img {
  height: 140px; width: auto; max-width: 100%; display: block;
  opacity: 0;
  animation: pl-logo-fade 0.8s 1.0s ease-out forwards;
}
@keyframes pl-logo-fade {
  from { opacity: 0; }
  to   { opacity: 0.55; }
}
.pl-logo::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: var(--cyan); box-shadow: 0 0 12px var(--cyan);
  animation: pl-wipe 0.8s 0.6s ease-out forwards;
}
@keyframes pl-wipe {
  0%   { top: 0; opacity: 1; }
  100% { top: 140px; opacity: 0; }
}

/* === Hero questions === */
.pl-questions {
  font-size: 1.75rem;
  font-weight: 300;
  line-height: 1.45;
  letter-spacing: -0.01em;
  margin: 0 0 3rem;
  min-height: 9rem;
}
.pl-questions .pl-q {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--fg);
  opacity: 0;
}
.pl-questions .pl-q.pl-q-dim { color: var(--fg-dim); }
.pl-questions .pl-q em {
  font-style: italic;
  font-weight: 500;
  color: var(--fg);
}
.pl-questions .pl-q::before {
  content: "> "; color: var(--cyan); font-family: var(--font-mono);
  font-size: 0.9em;
}
.pl-cursor {
  display: inline-block; width: 0.55em; height: 1.1em;
  background: var(--cursor); vertical-align: text-bottom;
  margin-left: 0.1em;
  animation: pl-blink 1s steps(2) infinite;
}
@keyframes pl-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* Glitch-split applied via JS by toggling .pl-glitch on the active line */
.pl-q.pl-glitch {
  text-shadow:
    -2px 0 var(--cyan),
    2px 0 #ff5ea6;
  animation: pl-glitch 0.14s ease-out forwards;
}
@keyframes pl-glitch {
  0%   { text-shadow: -2px 0 var(--cyan), 2px 0 #ff5ea6; }
  100% { text-shadow: none; }
}

/* === Body copy === */
.pl-body {
  color: var(--fg-dim);
  font-size: 1.65rem;
  line-height: 1.5;
  text-align: center;
}
.pl-body > p {
  margin: 0 0 1.5rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.9s ease-out, transform 0.9s ease-out;
}
.pl-body > p:last-child { margin-bottom: 0; }
body.pl-revealed .pl-body > p:nth-child(1) { opacity: 1; transform: none; transition-delay: 0s; }
body.pl-revealed .pl-body > p:nth-child(2) { opacity: 1; transform: none; transition-delay: 5s; }
body.pl-revealed .pl-body > p:nth-child(3) { opacity: 1; transform: none; transition-delay: 7s; }
body.pl-revealed .pl-body > p:nth-child(4) { opacity: 1; transform: none; transition-delay: 7.5s; }
.pl-body .pl-accent { color: var(--fg); }
.pl-body .pl-body-emphasis {
  font-size: 2.1rem;
  font-style: italic;
  color: var(--cyan);
  font-weight: 300;
  margin: 2rem 0;
  line-height: 1.4;
  letter-spacing: 0.005em;
}
.pl-body .pl-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(94,234,212,0.35);
  border-radius: 2px;
  margin-top: 0.5rem;
}

/* === Fugue === */
.pl-fugue {
  margin-top: 4rem;
  padding: 0;
  border: none;
  background: none;
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 400;
  color: var(--fg-dim);
  line-height: 1.5;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease-out 10s, transform 0.6s ease-out 10s;
}
body.pl-revealed .pl-fugue { opacity: 1; transform: translateY(0); }
.pl-fugue p {
  margin: 0 0 1.4rem;
  font-size: 1.7rem;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.pl-fugue p:last-of-type { margin-bottom: 0; }
body.pl-revealed .pl-fugue p:nth-of-type(1) { opacity: 1; transform: none; transition-delay: 10.8s; }
body.pl-revealed .pl-fugue p:nth-of-type(2) { opacity: 1; transform: none; transition-delay: 12.0s; }
body.pl-revealed .pl-fugue p:nth-of-type(3) { opacity: 1; transform: none; transition-delay: 13.2s; }
body.pl-revealed .pl-fugue p:nth-of-type(4) { opacity: 1; transform: none; transition-delay: 14.4s; }
body.pl-revealed .pl-fugue p:nth-of-type(5) { opacity: 1; transform: none; transition-delay: 16.0s; }
.pl-fugue-label {
  display: block;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 1.85rem;
}
.pl-fugue-coda {
  margin-top: 1.6rem !important;
  color: var(--cyan);
  font-size: 2.15rem !important;
  line-height: 1.35 !important;
}

/* === Signal strip === */
.pl-signal {
  margin-top: 2.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--fg-dim);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.75rem 0;
  height: 7.2rem;
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease-out 20.5s, transform 0.6s ease-out 20.5s;
}
body.pl-revealed .pl-signal { opacity: 1; transform: translateY(0); }
.pl-signal-row {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.55;
  transition: opacity 0.3s;
}
.pl-signal-row.pl-active { color: var(--cyan); opacity: 1; }

/* === Footer cards === */
.pl-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease-out 22s, transform 0.6s ease-out 22s;
}
body.pl-revealed .pl-footer { opacity: 1; transform: translateY(0); }
.pl-card {
  border: 1px solid var(--rule);
  background: rgba(14,19,26,0.6);
  padding: 1rem 1.1rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--fg-dim);
}
.pl-card-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
  display: block;
  margin-bottom: 0.5rem;
}
.pl-card a {
  color: var(--blue);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.pl-card a:hover { border-bottom-color: var(--blue); }
.pl-card a:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 2px;
}
.pl-card-body {
  display: block;
  margin-top: 0.4rem;
}

/* === Pseudo-coordinates column === */
.pl-coords {
  position: fixed;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: rgba(125,133,144,0.45);
  letter-spacing: 0.1em;
  line-height: 1.8;
  z-index: 8;
  pointer-events: none;
}

/* === Colophon === */
.pl-colophon {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 1.5rem;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  opacity: 0.5;
}

/* === Generic fade === */
@keyframes pl-fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === Responsive === */
@media (max-width: 640px) {
  main.pl-main { padding: 3rem 1.25rem 2.5rem; }
  .pl-logo { height: 90px; }
  .pl-logo img { height: 90px; }
  @keyframes pl-wipe-mobile {
    0%   { top: 0; opacity: 1; }
    100% { top: 90px; opacity: 0; }
  }
  .pl-logo::after { animation-name: pl-wipe-mobile; }
  .pl-questions { font-size: 1.25rem; }
  .pl-body { font-size: 1.2rem; }
  .pl-body > p { margin-bottom: 1.1rem; }
  .pl-body-emphasis { font-size: 1.55rem; margin: 1.4rem 0; }
  .pl-fugue { padding: 0; margin-top: 2.75rem; }
  .pl-fugue p { font-size: 1.25rem; margin-bottom: 1rem; }
  .pl-fugue-coda { font-size: 1.55rem !important; margin-top: 1.15rem !important; }
  .pl-fugue-label { font-size: 0.75rem; margin-bottom: 1.4rem; }
  .pl-footer { grid-template-columns: 1fr; }
  .pl-coords { display: none; }
}

/* === Reduced motion overrides === */
@media (prefers-reduced-motion: reduce) {
  .pl-status, .pl-body, .pl-body > p, .pl-fugue, .pl-fugue p, .pl-signal, .pl-footer { opacity: 1; animation: none; transition: none; transform: none; }
  .pl-logo img { opacity: 0.55; animation: none; }
  .pl-logo::after { display: none; }
  .pl-cursor { animation: none; }
  .pl-q { opacity: 1 !important; }
}
