/* Base resets, html/body, typography primitives, view switch,
 * persistent contact bar. Loaded after tokens.css on every page. */

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  height: 100%; width: 100%;
}

body {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* Keyboard focus. Amber ring, visible only for keyboard users (not mouse
 * clickers) via :focus-visible so the site stays clean for pointer users
 * but stays accessible for everyone else. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--amber, #c47c4a);
  outline-offset: 3px;
  border-radius: 2px;
}
a:focus-visible,
button:focus-visible,
.cta-link:focus-visible {
  outline-offset: 4px;
}

/* Skip-to-content link. Hidden off-screen until a keyboard user tabs to
 * it, then springs into the top-left corner. Click or Enter jumps them
 * past the nav/chrome to the main content of the page. */
.skip-link {
  position: fixed;
  top: -48px;
  left: 12px;
  z-index: 999;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 0;
  transition: top 160ms ease;
}
.skip-link:focus {
  top: 12px;
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

/* Site-wide hover tooltip. Injected by tooltip.js; styled in the
 * cartographer grammar to match panel treatment. Pointer-events
 * disabled so the tip never steals hovers from its own target. */
.site-tooltip {
  position: fixed;
  z-index: 200;
  top: -9999px;
  left: -9999px;
  max-width: 300px;
  background: var(--paper);
  border: 1px solid rgba(26, 24, 20, 0.4);
  padding: 11px 14px 12px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 140ms ease, transform 140ms ease;
  box-shadow: 0 6px 20px rgba(26, 24, 20, 0.08);
}
.site-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.site-tooltip .tip-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 5px;
}
.site-tooltip .tip-body {
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  margin: 0;
}

/* Make SVG-group elements (used for agent cards, module dots, etc.) feel
 * interactive when they carry a tooltip. Cursor swap + subtle opacity hint. */
[data-tip-title] {
  cursor: help;
}
g[data-tip-title] { transition: opacity 160ms ease; }
g[data-tip-title]:hover { opacity: 0.88; }

/* Scroll-triggered reveal animations. Applied to SVG paths (draw-in),
 * block elements (fade-up), and parent containers that cascade stagger
 * onto their children. Triggered by either the JS-added `.revealed`
 * class or the canvas engine's `.panel.active` class (so desktop canvas
 * pages animate on panel-in without needing the scroll observer). */

/* Draw-in for SVG paths and lines. Targets carry pathLength="1" so the
 * dash math normalizes across path geometries. */
[data-reveal="draw"] {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1000ms cubic-bezier(.4, 0, .2, 1);
}
[data-reveal="draw"].revealed,
.panel.active [data-reveal="draw"] {
  stroke-dashoffset: 0;
}

/* Fade-up: opacity + gentle vertical rise. Good for individual blocks. */
[data-reveal="fade-up"] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 520ms ease, transform 520ms ease;
}
[data-reveal="fade-up"].revealed,
.panel.active [data-reveal="fade-up"] {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children: observe the parent, cascade the reveal to children
 * with incrementing delays. Children carry the actual animated properties.
 * Used for timeline entries and grouped SVG elements. */
[data-reveal="stagger"] > * {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 480ms ease, transform 480ms ease;
}
[data-reveal="stagger"].revealed > *,
.panel.active [data-reveal="stagger"] > * {
  opacity: 1;
  transform: translateY(0);
}
[data-reveal="stagger"].revealed > *:nth-child(1),
.panel.active [data-reveal="stagger"] > *:nth-child(1)  { transition-delay: 60ms; }
[data-reveal="stagger"].revealed > *:nth-child(2),
.panel.active [data-reveal="stagger"] > *:nth-child(2)  { transition-delay: 140ms; }
[data-reveal="stagger"].revealed > *:nth-child(3),
.panel.active [data-reveal="stagger"] > *:nth-child(3)  { transition-delay: 220ms; }
[data-reveal="stagger"].revealed > *:nth-child(4),
.panel.active [data-reveal="stagger"] > *:nth-child(4)  { transition-delay: 300ms; }
[data-reveal="stagger"].revealed > *:nth-child(5),
.panel.active [data-reveal="stagger"] > *:nth-child(5)  { transition-delay: 380ms; }
[data-reveal="stagger"].revealed > *:nth-child(6),
.panel.active [data-reveal="stagger"] > *:nth-child(6)  { transition-delay: 460ms; }
[data-reveal="stagger"].revealed > *:nth-child(7),
.panel.active [data-reveal="stagger"] > *:nth-child(7)  { transition-delay: 540ms; }
[data-reveal="stagger"].revealed > *:nth-child(8),
.panel.active [data-reveal="stagger"] > *:nth-child(8)  { transition-delay: 620ms; }

/* SVG node reveal: for chain diagrams with circles/rects/text that
 * should pop in sequence. Uses opacity + scale at the element level. */
[data-reveal="chain"] > * {
  opacity: 0;
  transform: scale(0.94);
  transform-origin: center;
  transform-box: fill-box;
  transition: opacity 420ms ease, transform 420ms cubic-bezier(.3, 1.3, .5, 1);
}
[data-reveal="chain"].revealed > *,
.panel.active [data-reveal="chain"] > * {
  opacity: 1;
  transform: scale(1);
}
[data-reveal="chain"].revealed > *:nth-child(1),
.panel.active [data-reveal="chain"] > *:nth-child(1)  { transition-delay: 80ms; }
[data-reveal="chain"].revealed > *:nth-child(2),
.panel.active [data-reveal="chain"] > *:nth-child(2)  { transition-delay: 200ms; }
[data-reveal="chain"].revealed > *:nth-child(3),
.panel.active [data-reveal="chain"] > *:nth-child(3)  { transition-delay: 320ms; }
[data-reveal="chain"].revealed > *:nth-child(4),
.panel.active [data-reveal="chain"] > *:nth-child(4)  { transition-delay: 440ms; }
[data-reveal="chain"].revealed > *:nth-child(5),
.panel.active [data-reveal="chain"] > *:nth-child(5)  { transition-delay: 560ms; }
[data-reveal="chain"].revealed > *:nth-child(6),
.panel.active [data-reveal="chain"] > *:nth-child(6)  { transition-delay: 680ms; }
[data-reveal="chain"].revealed > *:nth-child(7),
.panel.active [data-reveal="chain"] > *:nth-child(7)  { transition-delay: 800ms; }
[data-reveal="chain"].revealed > *:nth-child(8),
.panel.active [data-reveal="chain"] > *:nth-child(8)  { transition-delay: 920ms; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal="draw"],
  [data-reveal="fade-up"],
  [data-reveal="stagger"] > *,
  [data-reveal="chain"] > * {
    opacity: 1 !important;
    transform: none !important;
    stroke-dashoffset: 0 !important;
    transition: none !important;
  }
}

/* View switch (landing <-> canvas) */
.view {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
  overflow: hidden;
}
.view.active {
  opacity: 1;
  pointer-events: auto;
}

/* Persistent contact footer. Rides every page. */
.contact-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 60;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.contact-bar .contact-link {
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
.contact-bar .contact-link:hover {
  color: var(--amber);
  border-color: var(--amber);
}
.contact-bar .channels span + span { margin-left: 22px; }
.contact-bar .bar-sig {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-soft);
}

/* Mobile contact bar collapse */
@media (max-width: 760px) {
  .contact-bar {
    position: static;
    padding: 10px 16px;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    width: 100%;
  }
  .contact-bar .channels {
    width: 100%;
    display: grid;
    gap: 4px;
  }
  .contact-bar .channels span + span { margin-left: 0; }
  .contact-bar .channels span { display: block; }
  .contact-bar .contact-link {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  html, body { overflow: auto; height: auto; }
  .view { position: relative; opacity: 1; pointer-events: auto; }
  .view:not(.active) { display: none; }
  .view.active { display: block; }
}
