/* Palette and type stack come from /tokens.css (single source of truth). */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;   /* fallback for browsers without dvh */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: var(--teal); }

header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 6px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}
.monogram { flex: 0 0 auto; line-height: 0; }
.head-text h1 { margin: 0; font-size: 18px; letter-spacing: .02em; }
.head-text p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

main {
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 16px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 760px;
}

/* the injected diagram svg scales to the stage width */
#diagram svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .04em;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s ease;
}
/* once the user has opened a panel the hint has done its job */
.hint.hint-done { opacity: 0 !important; }

/* prominent save-contact pill below the diagram (gold accent, >=44px tap) */
.cta-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 26px;   /* clears the hint that hangs below the stage */
  padding: 10px 26px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: rgba(255, 181, 71, .08);
  color: var(--gold);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  text-decoration: none;
}
.cta-save:hover, .cta-save:active { background: rgba(255, 181, 71, .16); }
.cta-save:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Save contact + Connect on LinkedIn sit side by side (wrap on narrow) */
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 26px;   /* clears the hint that hangs below the stage */
}
.cta-row .cta-save { margin-top: 0; }
.cta-linkedin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 26px;
  border: 1px solid var(--teal);
  border-radius: 999px;
  background: rgba(0, 212, 200, .06);
  color: var(--teal);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  text-decoration: none;
}
.cta-linkedin:hover, .cta-linkedin:active { background: rgba(0, 212, 200, .14); }
.cta-linkedin:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* no-JS / crawler fallback: essentials in plain text */
.noscript-fallback {
  max-width: 1000px;
  margin: 6px auto 0;
  padding: 10px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

/* selected box highlight (state, not motion). No SVG `filter` anywhere: iOS
   Safari renders animated filters unreliably, which hid the alive-pulse. */
.box-ring { opacity: 0; transition: opacity .2s ease; }
.box-ring.ring-on { opacity: 1; }
/* immediate flash on pointerdown, before the click even lands */
.box-ring.ring-press { opacity: 1; transition: none; }

/* Overlay motion layers are hidden by default; only the no-preference block,
   and only after the intro settles, makes them visible and animated. So under
   prefers-reduced-motion they stay invisible and the diagram is fully static. */
.flow-glow { clip-path: inset(0 100% 0 0); }
.node-halo, .node-ping, .box-breathe { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  /* intro: reveal the card left-to-right (clip wipe, iOS-safe). The card
     traces are filled ribbons, not strokes, so this stands in for a
     stroke-dashoffset draw-in. */
  #diagram.reveal svg { animation: cardWipe 1.6s cubic-bezier(.4, 0, .2, 1) both; }
  @keyframes cardWipe {
    from { clip-path: inset(0 100% 0 0); }
    to   { clip-path: inset(0 -2% 0 0); }
  }

  /* flowing pipes: a band of light sweeps left->right across brighter clones
     of the traces, so the pipes read as carrying flow forward */
  #diagram.settled .flow-glow { animation: flowSweep 3.8s linear infinite; }
  @keyframes flowSweep {
    0%   { clip-path: inset(0 100% 0 -25%); }
    100% { clip-path: inset(0 -25% 0 100%); }
  }

  /* nodes (start ring, the four + gateways, end event): the same pulse style
     for all -- a halo that breathes plus an expanding ping ring. No left-to-
     right motion here; that lives only in the pipes (.flow-glow). */
  #diagram.settled .node-halo { animation: nodeHalo 2.6s ease-in-out infinite; }
  @keyframes nodeHalo { 0%, 100% { opacity: .2; } 50% { opacity: .55; } }
  #diagram.settled .node-ping {
    transform-box: fill-box; transform-origin: center;
    animation: nodePing 2.6s ease-out infinite;
  }
  @keyframes nodePing {
    0%   { opacity: .7; transform: scale(.6); }
    100% { opacity: 0;  transform: scale(2.3); }
  }

  /* boxes: a barely-there halo breathe */
  #diagram.settled .box-breathe { animation: boxBreathe 4s ease-in-out infinite; }
  @keyframes boxBreathe { 0%, 100% { opacity: .05; } 50% { opacity: .16; } }

  /* hint fades in when the intro settles and stays until first panel open
     (.hint-done above wins and fades it out) */
  .hint.hint-show { opacity: .8; }

  /* battery: JS toggles .anim-paused on #diagram while the tab is hidden */
  #diagram.anim-paused .flow-glow,
  #diagram.anim-paused .node-halo,
  #diagram.anim-paused .node-ping,
  #diagram.anim-paused .box-breathe { animation-play-state: paused; }
}

@media (prefers-reduced-motion: reduce) {
  .hint { transition: none; }
}

/* invisible, accessible tap targets placed over the three boxes */
.tap {
  position: absolute;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  /* enforce a 44pt minimum hit area even if the box renders smaller */
  min-width: 44px;
  min-height: 44px;
}
.tap:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tap:active { background: rgba(0, 212, 200, .1); }

/* expansion panel */
.panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(5, 8, 16, .66);
  animation: overlayIn .18s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.panel-card {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 26px 22px 30px;
  animation: sheetIn .22s cubic-bezier(.4, 0, .2, 1);
}
@keyframes sheetIn { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }

.panel-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.panel-close:hover { color: var(--ink); border-color: var(--muted); }

.panel-tag {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: .08em;
}
.panel-card h2 {
  margin: 4px 0 6px;
  font-size: 20px;
  color: var(--ink);
}
.panel-lede {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}
.panel-points {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel-points li {
  position: relative;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.5;
}
.panel-points li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 7px;
  height: 7px;
  background: var(--teal);
}
.panel-points li:nth-child(even)::before { background: var(--gold); }

.panel-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 18px;
}
.tool-link {
  display: block;
  padding: 13px 16px;
  border: 1px solid var(--teal);
  border-radius: 10px;
  text-decoration: none;
  background: rgba(0, 212, 200, .06);
}
.tool-link strong { color: var(--teal); font-size: 14.5px; font-weight: 600; }
.tool-link span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tool-link:hover { background: rgba(0, 212, 200, .12); }

.panel-cta {
  display: inline-block;
  color: var(--gold);
  font-size: 13px;
  text-decoration: none;
}
.panel-cta:hover { text-decoration: underline; }

footer {
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
footer a { text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (min-width: 720px) {
  .panel { align-items: center; }
  .panel-card { border-radius: 16px; }
}

@media (max-width: 640px) {
  .head-text h1 { font-size: 16px; }
  .head-text p { font-size: 11.5px; }
}
