/* Landing: "One short text. A full research run." A real night photo of the Torres sector carries the section,
   like the hero. Over its sky the bus question flies into the model, five services find their piece and the facts
   fly back, then one orange answer leaves. Complete without JS; static under reduced motion. */

.brain { position: relative; isolation: isolate; overflow: hidden; color: var(--snow); padding: 88px 0 64px; }
.brain-photo { position: absolute; inset: 0; z-index: -1; display: block; }
.brain-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center 62%; display: block; }
/* legibility scrim only: night above blends out of the section before, the photo shows through the middle */
.brain-photo::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, var(--night) 0%, rgb(14 20 28 / .62) 16%, rgb(14 20 28 / .5) 50%, rgb(14 20 28 / .72) 84%, var(--night) 100%); }

.brain-in { max-width: 1380px; margin: 0 auto; padding-inline: clamp(16px, 5vw, 90px); }
.brain-head h2 { font-size: var(--t-2xl); line-height: 1; letter-spacing: -.02em; color: #fff;
  margin-bottom: .3em; text-shadow: 0 2px 24px rgb(0 0 0 / .35); }
.brain-head p { font-size: var(--t-lg); line-height: 1.45; color: rgb(255 255 255 / .82); max-width: 30em; text-shadow: 0 1px 12px rgb(0 0 0 / .6); margin: 0; }
.brain-head p b { color: #fff; font-weight: 600; }

/* ---------- the network ---------- */
.net { position: relative; margin: var(--s-6) 0 0; display: grid; align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.32fr) minmax(0, 1fr);
  grid-template-areas: "gps map bus" "q core a" "web tray wx" "tally tally tally" "cap cap cap"; gap: 36px clamp(28px, 4vw, 64px); }
.net > * { position: relative; z-index: 1; min-width: 0; }
.wires { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 0; }
.wire { fill: none; stroke: rgb(244 241 234 / .3); stroke-width: 1.5; stroke-dasharray: 2 6; stroke-linecap: round; transition: stroke .3s; }
.wire.hot { stroke: rgb(143 184 222 / .9); stroke-dasharray: none; }
.wire.out { stroke: rgb(242 92 31 / .9); stroke-dasharray: none; }
.pk { fill: var(--lake); filter: drop-shadow(0 0 6px rgb(143 184 222 / .9)); }
.pk.back { fill: #fff; filter: drop-shadow(0 0 6px rgb(255 255 255 / .9)); }
.pk.ans { fill: var(--dusk); filter: drop-shadow(0 0 8px rgb(242 92 31 / .9)); }
.fly { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; white-space: nowrap; }

.n-q { grid-area: q; }  .n-a { grid-area: a; }  .n-core { grid-area: core; }
.n-gps { grid-area: gps; align-self: end; } .n-map { grid-area: map; } .n-bus { grid-area: bus; align-self: end; }
.n-web { grid-area: web; align-self: start; } .n-wx { grid-area: wx; align-self: start; } .tray { grid-area: tray; }

.net .lcd { margin: 0; padding: 12px; box-shadow: inset 0 2px 8px rgb(0 0 0 / .18), var(--shadow); }
.net .lcd .msg { max-width: none; font-size: var(--t-sm); }
.net .lcd .meta { font-size: var(--t-xs); }
.net .bubble { width: 100%; font-size: var(--t-base); line-height: 1.4; padding: 14px 18px 12px; }
.net .bubble small { font-size: .78em; }
.net .bubble.ask { border-radius: 14px 14px 4px 14px; }
.net .bubble.ans { border-radius: 14px 14px 14px 4px; }

/* the model */
.core { justify-self: center; width: 150px; aspect-ratio: 1; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: rgb(14 20 28 / .92); border: 2px solid var(--snow); box-shadow: var(--shadow); }
.core { justify-items: center; gap: 2px; }
.core-brain { width: 40px; height: 40px; fill: none; stroke: var(--snow); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: stroke .4s; }
.core b { font-family: var(--display); font-size: var(--t-xl); font-weight: 700; line-height: 1; letter-spacing: .02em; }
.core.working .core-brain { stroke: var(--lake); animation: think 1.6s ease-in-out infinite; }
@keyframes think { 50% { transform: scale(1.08); } }
.core-ring { position: absolute; inset: -12px; border-radius: 50%; border: 1.5px dashed rgb(143 184 222 / .5); transition: border-color .4s; }
.core.working .core-ring { border-color: var(--lake); animation: spin 7s linear infinite; }   /* turns only while it works */
.core-state { position: absolute; top: calc(100% + 26px); left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: var(--t-xs); font-weight: 600; color: rgb(255 255 255 / .75); }
@keyframes spin { to { transform: rotate(360deg); } }

/* facts gathered */
.tray { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; align-self: start; padding-top: 8px; }
.tray li, .fly { margin: 0; padding: .32em .8em .28em; border-radius: 999px; font-size: var(--t-sm); font-weight: 600; line-height: 1.3;
  background: rgb(33 44 57 / .94); border: 1px solid rgb(143 184 222 / .45); color: #fff; font-variant-numeric: tabular-nums; }

/* ---------- service cards ---------- */
.svc { container-type: inline-size; background: rgb(14 20 28 / .86); border: 1px solid rgb(244 241 234 / .1); border-radius: 14px; padding: 14px 16px 16px;
  box-shadow: var(--shadow); transition: opacity .4s, border-color .4s; }
.svc header { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 11px; align-items: center; margin-bottom: 12px; }
.svc header svg { grid-row: span 2; width: 36px; height: 36px; padding: 8px; border-radius: 50%; background: var(--slate-2);
  fill: none; stroke: var(--lake); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.svc header b { font-size: var(--t-sm); font-weight: 700; line-height: 1.2; }
.svc header span { font-size: var(--t-xs); color: var(--mist); line-height: 1.3; }

/* position */
.gps-body { display: flex; align-items: center; gap: 14px; }
.radar { position: relative; flex: none; width: 52px; height: 52px; border-radius: 50%; background: rgb(143 184 222 / .1); }
.radar::after { content: ""; position: absolute; inset: 20px; border-radius: 50%; background: var(--lake); box-shadow: 0 0 0 3px var(--night); }
.radar i { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgb(143 184 222 / .5); }
.radar i:nth-child(2) { inset: 9px; } .radar i:nth-child(3) { inset: 17px; }
.gps-body > div { min-width: 0; }
.gps-xy { font-family: var(--display); font-size: min(1.75rem, 9cqi); font-weight: 700; line-height: 1.1; margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gps-at { font-size: var(--t-sm); color: var(--mist); margin: 2px 0 0; }

/* map, drawn from OpenStreetMap */
.map { position: relative; aspect-ratio: 2 / 1; border-radius: var(--r-1); overflow: hidden; background: #111922; }
.map > svg { display: block; width: 100%; height: 100%; }
.map-dist svg { width: 16px; height: 16px; }
.m-water { fill: #1a2e41; stroke: #22405a; stroke-width: .8; }
.m-stream { fill: none; stroke: #21384d; stroke-width: .8; }
.m-river { fill: none; stroke: #27486a; stroke-width: 2.2; stroke-linejoin: round; }
.m-trail { fill: none; stroke: #2e3b4a; stroke-width: .8; stroke-dasharray: 2 2.5; }
.m-minor { fill: none; stroke: #34424f; stroke-width: 1.3; stroke-linecap: round; }
.m-road { fill: none; stroke: #55657a; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.m-route-bg { fill: none; stroke: rgb(143 184 222 / .22); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.m-route { fill: none; stroke: var(--lake); stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.m-you { fill: var(--lake); stroke: #fff; stroke-width: 1.6; }
.m-you-halo { fill: rgb(143 184 222 / .28); }
.m-stop path { fill: #fff; stroke: var(--night); stroke-width: 1.5; }
.m-stop circle { fill: var(--night); }
.map-tag { position: absolute; transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; font-size: var(--t-xs); font-weight: 700; line-height: 1.2;
  padding: 3px 7px; border-radius: 4px; background: rgb(14 20 28 / .88); color: #fff; }
.map-tag.tag-you { color: var(--lake); }
.map-tag.tag-stop { transform: translate(-82%, -100%); }   /* the stop sits near the right edge */
.map-dist { position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 4px; font-size: .8125rem; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: rgb(14 20 28 / .9); border: 1px solid rgb(143 184 222 / .45); }

/* departures */
.deps { list-style: none; margin: 0; padding: 0; }
.deps li { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 12px; align-items: baseline; margin: 0; max-width: none; padding: 8px 0; border-top: 1px solid var(--line); }
.deps svg, .results svg, .map-dist svg { fill: none; stroke: var(--lake); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.deps svg { align-self: center; }
.deps b { font-family: var(--display); font-size: 1.75rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.deps span { font-size: var(--t-sm); color: var(--mist); line-height: 1.3; }
.deps em { font-style: normal; font-size: var(--t-sm); font-weight: 600; }

/* weather */
.hours { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; text-align: center; }
.hours li { display: grid; justify-items: center; gap: 4px; margin: 0; }
.hours .h { font-size: var(--t-xs); color: var(--mist); font-variant-numeric: tabular-nums; }
.hours svg { width: 26px; height: 26px; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hours b { font-size: var(--t-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.hours i { position: relative; width: 6px; height: 34px; border-radius: 999px; background: rgb(143 184 222 / .16); overflow: hidden; }
.hours i::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--p); background: var(--lake); border-radius: 999px; transition: height .6s cubic-bezier(.16, 1, .3, 1); transition-delay: calc(var(--i) * 70ms); }
.g-sun { stroke: #f2c14e; } .g-sun circle { fill: rgb(242 193 78 / .22); }
.g-cloud { stroke: #fff; fill: rgb(244 241 234 / .14); }
.g-rain { stroke: var(--lake); }
.wx-sum { margin: 10px 0 0; font-size: var(--t-sm); line-height: 1.35; }

/* web */
.query { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 6px 12px; border-radius: 999px; background: var(--slate-2);
  border: 1px solid var(--line-strong); font-size: var(--t-sm); }
.query svg { flex: none; width: 15px; height: 15px; fill: none; stroke: var(--mist); stroke-width: 2; stroke-linecap: round; }
.query span { min-width: 0; }
.results { list-style: none; margin: 0; padding: 0; }
.results li { margin: 0; max-width: none; padding: 7px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 8px; }
.results svg { grid-row: span 2; margin-top: 2px; }
.results li:first-child { border-top: 0; }
.results b { display: block; font-size: var(--t-sm); font-weight: 700; line-height: 1.3; color: var(--lake); }
.results span { font-size: .8125rem; color: var(--mist); line-height: 1.35; }
.results mark { white-space: nowrap; background: none; color: #fff; font-weight: 700; box-shadow: inset 0 -2px 0 rgb(143 184 222 / .7); }

/* small in, big research, small out */
.tally { grid-area: tally; margin: 8px auto 0; max-width: none; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 6px 0;
  font-family: var(--display); font-size: clamp(1.25rem, .95rem + 1vw, 1.75rem); font-weight: 600; line-height: 1.2; color: rgb(255 255 255 / .78); text-align: center; }
.tally > span + span::before { content: "→"; margin: 0 .6em; color: var(--lake); font-weight: 400; }
.tally b { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.tally .t-out b { color: var(--dusk); }
.net figcaption { grid-area: cap; text-align: center; font-size: var(--t-xs); color: rgb(255 255 255 / .62); margin-top: 4px; }
.n-replay, .n-skip { font: inherit; font-weight: 700; color: var(--link); background: none; border: 0; padding: 4px 2px; margin-left: 8px; cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.n-replay:hover, .n-skip:hover { text-decoration-thickness: 2px; }

/* ---------- playback: JS adds .armed, then steps each part through busy -> done ---------- */
.armed .n-q, .armed .n-a { opacity: 0; transform: translateY(12px); transition: opacity .8s cubic-bezier(.16, 1, .3, 1), transform .8s cubic-bezier(.16, 1, .3, 1); }
.armed.asked .n-q, .armed.answered .n-a { opacity: 1; transform: none; }
.armed .tray li { opacity: 0; transform: scale(.8); transition: opacity .35s, transform .45s cubic-bezier(.16, 1, .3, 1); }
.armed .tray li.on { opacity: 1; transform: none; }

.armed .svc { opacity: .55; }
.armed .svc.busy, .armed .svc.done { opacity: 1; }
.armed .svc.busy { border-color: rgb(143 184 222 / .7); }
.armed .svc.busy header svg { animation: ask .9s cubic-bezier(.16, 1, .3, 1) infinite; }
@keyframes ask { from { box-shadow: 0 0 0 0 rgb(143 184 222 / .5); } to { box-shadow: 0 0 0 10px rgb(143 184 222 / 0); } }
.armed .gps-body > div, .armed .map-tag, .armed .map-dist, .armed .wx-sum, .armed .results li, .armed .deps li {
  opacity: 0; transition: opacity .45s, translate .6s cubic-bezier(.16, 1, .3, 1); translate: 0 6px; }
.armed .svc.done .gps-body > div, .armed .svc.done .map-tag, .armed .svc.done .map-dist, .armed .svc.done .wx-sum,
.armed .svc.busy .deps li, .armed .svc.done .deps li, .armed .svc.done .results li { opacity: 1; translate: 0 0; }
.armed .deps li:nth-child(2), .armed .results li { transition-delay: calc(var(--i, 1) * 120ms + 150ms); }
.armed .svc.busy .radar i { animation: ping 1.2s cubic-bezier(.16, 1, .3, 1) infinite; }
.armed .svc.busy .radar i:nth-child(2) { animation-delay: .2s; } .armed .svc.busy .radar i:nth-child(3) { animation-delay: .4s; }
@keyframes ping { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
.armed .m-route { stroke-dashoffset: 1; transition: stroke-dashoffset 1.4s cubic-bezier(.45, 0, .2, 1); }
.armed .svc.busy .m-route, .armed .svc.done .m-route { stroke-dashoffset: 0; }
.armed .m-stop { transform: scale(0); transition: transform .5s cubic-bezier(.16, 1, .3, 1) .9s; }
.armed .svc.busy .m-stop, .armed .svc.done .m-stop { transform: none; }
.armed .hours li { opacity: 0; transform: translateY(6px) scale(.9); transition: opacity .35s, transform .5s cubic-bezier(.16, 1, .3, 1); transition-delay: calc(var(--i) * 90ms); }
.armed .svc.busy .hours li, .armed .svc.done .hours li { opacity: 1; transform: none; }
.armed .hours i::after { height: 0; }
.armed .svc.done .hours i::after { height: var(--p); }
.armed .query span { clip-path: inset(0 100% 0 0); transition: clip-path .9s steps(18, end); }
.armed .svc.busy .query span, .armed .svc.done .query span { clip-path: inset(0); }

/* ---------- responsive ---------- */
@media (min-width: 1100px) {
  .brain { padding: 72px 0 56px; }
  .brain-head h2 { font-size: clamp(2rem, 1.3rem + 1.9vw, 3rem); }
  .brain-head p { font-size: var(--t-base); }
  .net { grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr) minmax(0, 1fr); gap: 28px clamp(24px, 3.2vw, 52px); margin-top: var(--s-5); }
  .svc { padding: 12px 14px 13px; }
  .svc header { grid-template-columns: 30px minmax(0, 1fr); column-gap: 9px; margin-bottom: 9px; }
  .svc header svg { width: 30px; height: 30px; padding: 6px; }
  .svc header b { font-size: var(--t-xs); }
  .svc header span { font-size: .75rem; }
  .radar { width: 40px; height: 40px; } .radar::after { inset: 15px; } .radar i:nth-child(2) { inset: 7px; } .radar i:nth-child(3) { inset: 13px; }
  .gps-xy { font-size: min(var(--t-lg), 9cqi); }
  .gps-at, .deps span, .deps em, .wx-sum, .query, .results b { font-size: var(--t-xs); }
  .results span { font-size: .75rem; }
  .deps li { padding: 6px 0; gap: 9px; }
  .deps b { font-size: var(--t-lg); }
  .hours svg { width: 20px; height: 20px; }
  .hours b { font-size: var(--t-xs); }
  .hours i { height: 26px; }
  .map-tag, .map-dist { font-size: .75rem; }
  .net .lcd { padding: 9px; border-width: 8px; }
  .net .lcd .msg { font-size: var(--t-xs); }
  .net .bubble { font-size: var(--t-sm); padding: 12px 16px 10px; }
  .tray li, .fly { font-size: var(--t-xs); }
  .core-state { top: calc(100% + 20px); }
  .tally { font-size: clamp(1.0625rem, .8rem + .6vw, 1.375rem); }
}
@media (max-width: 1099px) {
  .net { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "q q" "core core" "map map" "gps bus" "wx web" "tray tray" "a a" "tally tally" "cap cap"; gap: 20px; }
  .wires, .fly { display: none; }
  .core { width: 150px; margin: 8px 0 16px; }
  .core-state { display: none; }   /* the answer and tally close the stack instead */
  .armed .m-route { transition-duration: .6s; }   /* phones: quick enough for a fast scroll */
  .armed .m-stop { transition-delay: .3s; }
  .armed .hours li { transition-delay: calc(var(--i) * 45ms); }
  .n-gps, .n-bus, .n-web, .n-wx { align-self: stretch; }
  .net .lcd { max-width: 30em; width: 100%; justify-self: end; }
  .net .bubble.ans { max-width: 30em; justify-self: start; }
}
@media (max-width: 899px) {
  .brain { padding: 72px 0 48px; }
  .brain-photo { bottom: auto; height: min(1100px, 150vw); }
  .brain-photo img { object-position: 50% 35%; }
}
@media (max-width: 639px) {
  .net { grid-template-columns: minmax(0, 1fr); grid-template-areas: "q" "core" "map" "gps" "bus" "wx" "web" "tray" "a" "tally" "cap"; gap: 16px; }
  .tally { flex-direction: column; align-items: center; }
  .tally > span + span::before { content: "↓"; display: block; margin: 0 0 4px; }
  .svc { padding: 12px 14px 14px; }
  .hours svg { width: 22px; height: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .net *, .net *::after { transition: none !important; animation: none !important; }
}
