/* Synapse project site. Colours mirror the logo and the talk:
   Protocol = blue, Topology = purple, Policy = magenta, chip/text = ink. */

@font-face { font-family: "Plex Sans"; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --bg: #FFFFFF;
  --bg-alt: #F4F6FA;
  --ink: #13213C;
  --ink-2: #3A4760;
  --muted: #5B6577;
  --line: #DCE1EA;
  --protocol: #1155CC;
  --topology: #674EA7;
  --policy: #A64D79;
  --protocol-bg: #E4EDFA;
  --topology-bg: #EEE9F6;
  --policy-bg: #F6E8EF;
  --ok: #2E6B1F;
  --ok-bg: #E7F2E2;
  --code-bg: #13213C;
  --code-ink: #E8EDF5;
  --sans: "Plex Sans", system-ui, sans-serif;
  --mono: "Plex Mono", ui-monospace, monospace;
  --wrap: 1120px;
}

/* light is the default; the header toggle sets data-theme="dark" on <html> */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1A2E;
  --bg-alt: #132440;
  --ink: #E8EDF5;
  --ink-2: #C3CCDB;
  --muted: #A3AFC2;
  --line: #2A3D5F;
  --protocol: #86AEF2;
  --topology: #BBAEDD;
  --policy: #DDABC4;
  --protocol-bg: #1B3157;
  --topology-bg: #2A2650;
  --policy-bg: #3A2440;
  --ok: #9BCF8A;
  --ok-bg: #1E3A22;
  --code-bg: #08111F;
  --code-ink: #E8EDF5;
}

/* logo colours as variables so the inline hero mark follows the theme */
:root { --ok-rgb: 46, 107, 31; --muted-rgb: 91, 101, 119; --glow: 17, 85, 204; --m-ink: #13213C; --m-in: #1155CC; --m-topo: #674EA7; --m-out: #A64D79; }
:root[data-theme="dark"] { --ok-rgb: 155, 207, 138; --muted-rgb: 163, 175, 194; --glow: 134, 174, 242; --m-ink: #E6ECF5; --m-in: #6D9EEB; --m-topo: #B4A7D6; --m-out: #D5A6BD; }
body, .site-head, .section, .site-foot, .spec, .out, .scn, .stage, .btn { transition: background-color .25s ease, border-color .25s ease, color .25s ease; }

/* theme toggle */
.head-right { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.theme-toggle { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.theme-toggle:hover { background: var(--bg-alt); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .moon { display: block; }
.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }

/* motion: messages crossing the synaptic cleft in the logo, and the three specs fusing in Synapse.
   The logo loop is CSS (3 s); the figure is driven by one clock in index.html (3.6 s).
   Nothing moves when the visitor asks for reduced motion. */
.hero-mark svg { width: 100%; height: auto; display: block; }
@media (prefers-reduced-motion: no-preference) {
  .hero-mark .msg { animation: fire 3s cubic-bezier(.45, 0, .25, 1) infinite; }
  .hero-mark .m2 { animation-delay: .06s; }
  .hero-mark .m3 { animation-delay: .12s; }
  .hero-mark .bulb { animation: charge 3s ease-in-out infinite; transform-origin: 44px 50px; }
  .hero-mark .cup { animation: receive 3s ease-out infinite; }
}
@media (prefers-reduced-motion: reduce) {
  .wire .ball { display: none; }
}
/* dots sink into the cup, then new ones leave the bulb and cross the cleft */
@keyframes fire {
  0%, 48% { transform: translateX(0); opacity: 1; }
  55% { transform: translateX(3px); opacity: 0; }
  56% { transform: translateX(-4px); opacity: 0; }
  62% { opacity: 1; }
  80%, 100% { transform: translateX(0); opacity: 1; }
}
@keyframes charge { 0%, 52% { transform: scale(1); } 58% { transform: scale(1.14); } 68%, 100% { transform: scale(1); } }
@keyframes receive { 0%, 48% { stroke-width: 6; } 54% { stroke-width: 7.6; } 64%, 100% { stroke-width: 6; } }

/* author links */
.people a { color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--line); padding-bottom: 2px; }
.people a:hover { border-bottom-color: var(--protocol); color: var(--protocol); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 18px/1.6 var(--sans); }
a { color: var(--protocol); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--protocol); outline-offset: 3px; border-radius: 4px; }
code, pre { font-family: var(--mono); }
img { display: block; max-width: 100%; height: auto; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.only-dark { display: none; }
[data-theme="dark"] .only-light { display: none; }
[data-theme="dark"] .only-dark { display: block; }

/* header */
.site-head { border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 22px; letter-spacing: -0.01em; }
.brand img { width: 36px; height: 36px; }
.site-nav { display: flex; gap: 4px 20px; flex-wrap: wrap; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-size: 16px; padding: 10px 0; }
.site-nav a:hover { color: var(--ink); text-decoration: underline; }

/* hero */
.hero { padding: 64px 0 72px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 48px; }
.hero h1 { font-size: clamp(56px, 9vw, 96px); line-height: 1; letter-spacing: -0.03em; font-weight: 600; margin: 0 0 16px; }
.tagline { font-size: clamp(20px, 2.6vw, 32px); line-height: 1.25; letter-spacing: -0.01em; font-weight: 600; color: var(--ink-2); margin: 0 0 32px; }
.tagline span { display: block; }   /* the paper title on two lines, split as on the slides */
.hero-mark { flex-shrink: 0; width: 260px; }

/* demo: a fourth button; the video opens in a dialog over the page */
.demo-btn { gap: 10px; }
.demo-btn svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.demo-dialog { padding: 0; border: 0; border-radius: 10px; background: #000; width: min(94vw, 160vh, 1854px); max-width: none; max-height: none; overflow: hidden; }
.demo-dialog::backdrop { background: rgba(8, 14, 26, .85); }
.demo-dialog video { display: block; width: 100%; height: auto; }
.demo-close { position: absolute; top: 10px; right: 10px; z-index: 1; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; }
.demo-close:hover { background: rgba(0, 0, 0, .85); }
.demo-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { display: inline-flex; align-items: center; min-height: 48px; padding: 0 22px; border-radius: 8px; font-weight: 600; font-size: 17px; text-decoration: none; border: 2px solid var(--ink); color: var(--ink); background: transparent; }
.btn:hover { background: var(--bg-alt); text-decoration: none; }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }

/* hero figure: three specs -> Synapse -> controllers (mirrors the talk's Promise slide) */
.flow { margin: 64px 0 0; padding-top: 40px; border-top: 3px solid var(--ink); display: grid; grid-template-columns: minmax(0, 1fr) 120px auto 120px minmax(0, 1fr); align-items: center; }
.wire { display: block; width: 120px; height: 168px; overflow: visible; }
.wire .w { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.w-p { stroke: var(--protocol); } .w-t { stroke: var(--topology); } .w-y { stroke: var(--policy); }
.w-g { stroke: var(--ok); } .w-c { stroke: var(--muted); stroke-dasharray: 5 6; }
.wire .head { fill: var(--ink); } .wire .head-g { fill: var(--ok); } .wire .head-c { fill: var(--muted); }
.ball.b-p { fill: var(--protocol); filter: drop-shadow(0 0 4px var(--protocol)); }
.ball.b-t { fill: var(--topology); filter: drop-shadow(0 0 4px var(--topology)); }
.ball.b-y { fill: var(--policy); filter: drop-shadow(0 0 4px var(--policy)); }
.ball.b-g { fill: var(--ok); filter: drop-shadow(0 0 4px var(--ok)); }
.ball.b-c { fill: var(--muted); }
.arrow-v { display: none; }
.flow figcaption { grid-column: 1 / -1; font-size: 16px; color: var(--muted); margin-top: 28px; }
.specs { display: flex; flex-direction: column; justify-content: space-between; height: 168px; }
.spec { height: 48px; border-radius: 8px; padding: 0 16px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border: 2px solid var(--c); background: var(--cb); }
.spec b { color: var(--c); font-weight: 600; }
.spec span { font: 400 15px var(--mono); color: var(--ink); text-align: right; }
.spec.protocol { --c: var(--protocol); --cb: var(--protocol-bg); }
.spec.topology { --c: var(--topology); --cb: var(--topology-bg); }
.spec.policy { --c: var(--policy); --cb: var(--policy-bg); }
.engine { text-align: center; }
.engine-box { display: inline-flex; align-items: center; gap: 12px; padding: 18px 26px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.engine-box img { width: 44px; height: 44px; }
/* pulses set by the figure script: --pulse runs 0 -> 1 once per loop, the ring grows and fades */
.engine-box, .out { --pulse: 0; --bump: 0; }
.engine-box { transform: scale(calc(1 + var(--bump) * .04)); box-shadow: 0 0 0 calc(var(--pulse) * 18px) rgba(var(--glow), calc((1 - var(--pulse)) * .45)); }
.out.done { box-shadow: 0 0 0 calc(var(--pulse) * 12px) rgba(var(--ok-rgb), calc((1 - var(--pulse)) * .4)); }
.out.wip { box-shadow: 0 0 0 calc(var(--pulse) * 12px) rgba(var(--muted-rgb), calc((1 - var(--pulse)) * .25)); }
.wire .run { fill: none; stroke: none; }
.outs { display: flex; flex-direction: column; justify-content: center; gap: 16px; height: 168px; }
.out { height: 64px; display: flex; align-items: center; gap: 14px; border-radius: 10px; padding: 0 16px; }
.out .logo { width: 40px; height: 40px; flex-shrink: 0; background: #FFFFFF; border-radius: 8px; padding: 4px; }
.out b { display: block; font-weight: 600; line-height: 1.3; font-size: 16px; white-space: nowrap; }
.out small { display: block; font-size: 15px; color: var(--ink-2); }
.out.done { border: 2px solid var(--ok); }
.out.wip { border: 2px dashed var(--muted); }
.out .tag { margin-left: auto; font-size: 13px; font-weight: 600; white-space: nowrap; }
.out.done .tag { color: var(--ok); }
.out.wip .tag { color: var(--muted); }

/* sections */
.section { padding: 72px 0; border-top: 1px solid var(--line); }
.section.alt { background: var(--bg-alt); }
.section h2 { font-size: clamp(28px, 3.4vw, 36px); line-height: 1.2; letter-spacing: -0.015em; font-weight: 600; margin: 0 0 16px; }
.section h3 { font-size: 21px; line-height: 1.3; font-weight: 600; margin: 0 0 8px; }
/* section text runs the full width of the content column, like the figures below it */
.section .intro { color: var(--ink-2); margin: 0 0 40px; font-size: 19px; }
.prose p { margin: 0 0 16px; font-size: 19px; }

/* abstract controller: three FSMs */
.fsms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin: 0 0 56px; }
.fsm { border-left: 5px solid var(--c); padding: 4px 0 4px 20px; }
.fsm p { margin: 0; color: var(--ink-2); }
.fsm.client, .fsm.manager { --c: var(--protocol); }
.fsm.policy { --c: var(--policy); }
.tuple { font-family: var(--mono); font-weight: 500; white-space: nowrap; }

/* pipeline */
.pipeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1.3fr 1fr 1fr; }
.stage { position: relative; padding: 24px 28px 24px 20px; border: 2px solid var(--ink); margin-right: 28px; border-radius: 10px; background: var(--bg); }
.stage:not(:last-child)::after { content: ""; position: absolute; right: -30px; top: 50%; width: 28px; height: 2px; background: var(--ink); }
.stage:not(:last-child)::before { content: ""; position: absolute; right: -31px; top: calc(50% - 6px); border: 7px solid transparent; border-left: 9px solid var(--ink); border-right: 0; }
.stage:last-child { margin-right: 0; }
.stage h3 { font-size: 18px; margin-bottom: 6px; }
.stage p { margin: 0; font-size: 16px; color: var(--ink-2); line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font: 500 14px/1 var(--mono); padding: 6px 8px; border-radius: 6px; background: var(--protocol-bg); color: var(--protocol); }
.chip.topology { background: var(--topology-bg); color: var(--topology); }
.chip.policy { background: var(--policy-bg); color: var(--policy); }

/* try it */
.codeblock { position: relative; margin: 0 0 16px; }
.codeblock pre { margin: 0; background: var(--code-bg); color: var(--code-ink); padding: 22px 24px; border-radius: 10px; overflow-x: auto; font-size: 15px; line-height: 1.7; }
.codeblock .cmt { color: #9AA8BF; }
.copy { position: absolute; top: 10px; right: 10px; min-height: 36px; padding: 0 12px; border-radius: 6px; border: 1px solid #3A4E73; background: #1C2D4D; color: #E8EDF5; font: 500 14px var(--sans); cursor: pointer; }
.copy:hover { background: #26395F; }
.note { font-size: 16px; color: var(--muted); margin: 0; }
.quick { max-width: 760px; margin-bottom: 48px; }
.repro { display: flex; flex-wrap: wrap; align-items: center; gap: 24px 56px; margin-bottom: 48px; }
.repro .quick { flex: 1 1 min(520px, 100%); min-width: 0; margin-bottom: 0; }
.badges { display: flex; gap: 16px; }
.badges img { width: 96px; height: 96px; display: block; }

.scenarios { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.scn { background: var(--bg); border: 2px solid var(--ink); border-radius: 10px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.scn svg { width: 64px; height: 48px; color: var(--ink); }
.scn h3 { font-size: 19px; margin: 0; }
.scn p { margin: 0; font-size: 16px; color: var(--ink-2); line-height: 1.45; }
.scn dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; font-size: 15px; align-items: baseline; }
.scn dt { color: var(--muted); }
.scn dd { margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.scn dd .chip { font-size: 13px; padding: 4px 6px; }
.scn .run { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.scn .run code { font-weight: 500; white-space: nowrap; }
.scn .run span { color: var(--muted); }

/* build on synapse */
.ways { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; }
.way { border-top: 5px solid var(--c); padding-top: 18px; }
.way.use { --c: var(--protocol); }
.way.extend { --c: var(--topology); }
.way.share { --c: var(--policy); }
.way h3 { font-size: 24px; margin-bottom: 10px; }
.way p { margin: 0 0 14px; color: var(--ink-2); }
.way ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }

/* cite, people, footer */
.people { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 0 0 12px; padding: 0; list-style: none; font-size: 19px; font-weight: 600; }
.site-foot { border-top: 1px solid var(--line); padding: 40px 0 56px; font-size: 16px; color: var(--muted); }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 16px 40px; align-items: center; justify-content: space-between; }
.site-foot img { width: 160px; }

/* below this width the five-column figure no longer fits: stack it */
@media (max-width: 1100px) {
  .wire { display: none; }
  .flow { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .specs, .outs { height: auto; gap: 12px; }
  .arrow-v { display: block; position: relative; width: 2px; height: 36px; margin: 12px auto; background: var(--ink); }
  .arrow-v::after { content: ""; position: absolute; left: -6px; bottom: -2px; border: 7px solid transparent; border-top: 10px solid var(--ink); border-bottom: 0; }
}
@media (max-width: 1000px) {
  .scenarios { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .hero-mark { display: none; }
  .pipeline { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .stage { margin-right: 0; }
  .stage:not(:last-child)::after { right: auto; left: 40px; top: auto; bottom: -30px; width: 2px; height: 28px; }
  .stage:not(:last-child)::before { right: auto; left: 34px; top: auto; bottom: -31px; border: 7px solid transparent; border-top: 9px solid var(--ink); border-bottom: 0; }
  .fsms, .ways { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}
@media (max-width: 600px) {
  .head-right { display: contents; }
  .site-head .wrap { padding-top: 12px; padding-bottom: 4px; row-gap: 4px; }
  .site-nav { order: 2; width: 100%; gap: 0 16px; }
  .site-nav a { font-size: 15px; padding: 8px 0; }
  body { font-size: 17px; }
  .hero { padding: 44px 0 56px; }
  .section { padding: 56px 0; }
  .scenarios { grid-template-columns: minmax(0, 1fr); }
}
