/* /projects/: the index. One entry per project on a hairline, newest first: its drawing, its number, period
   and tag, its title and its one line. The title's link covers the whole entry. Hover, keyboard focus or, on a
   touch screen, the middle of the screen (index.js sets .live) brings an entry alive: the hairline fills with
   the accent, an arrow comes in and the drawing runs. With reduced motion nothing moves. */

/* The accent pairs of the project pages (style.css, .post[data-accent]). Each reads at 4.5 : 1 or better on its page. */
.work { --accent: var(--text); --accent-2: var(--gray-600); }
.work[data-accent="agent"] { --accent: #7aa2ff; --accent-2: #b4a6ff; }
.work[data-accent="nba"] { --accent: #6d8dff; --accent-2: #ff9a4d; }
.work[data-accent="sentiment"] { --accent: #2fd3bf; --accent-2: #a98bff; }
.work[data-accent="monitor"] { --accent: #4cc3f7; --accent-2: #9adcfb; }
:root[data-theme="light"] .work[data-accent="agent"] { --accent: #2a55c9; --accent-2: #5b45c4; }
:root[data-theme="light"] .work[data-accent="nba"] { --accent: #2a52e0; --accent-2: #b4500f; }
:root[data-theme="light"] .work[data-accent="sentiment"] { --accent: #0b7c6f; --accent-2: #6a3fd0; }
:root[data-theme="light"] .work[data-accent="monitor"] { --accent: #0670a3; --accent-2: #0a5a85; }

.works { list-style: none; margin: 2.5rem 0 0; padding: 0; border-bottom: 1px solid var(--line); }
.work {
  /* The drawing's quiet lines and its filled areas: the accent mixed into the page's line and page colours. */
  --mk-line: color-mix(in srgb, var(--accent) 40%, var(--line));
  --mk-soft: color-mix(in srgb, var(--accent) 8%, var(--page));
  --mk-soft-2: color-mix(in srgb, var(--accent) 17%, var(--page));
  position: relative;
  display: grid;
  grid-template-columns: min(15rem, 38%) minmax(0, 1fr);
  column-gap: 2rem;
  align-items: center;
  padding: 2rem 0;
  border-top: 1px solid var(--line);
}
/* The hairline in the accent, drawn from the left when the entry comes alive. */
.work::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.work-mark { order: -1; }
.work-mark svg { display: block; width: 100%; height: auto; overflow: visible; }

.work-text { display: flex; flex-direction: column; min-width: 0; }
.work-meta { order: -1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; margin: 0; font: 400 0.8125rem/1.5 var(--mono); color: var(--gray-500); }
.work-no { color: var(--accent); }
.work h2 { margin-top: 0.5rem; font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.025em; }
.work h2 a, .work h2 a:hover { color: var(--text); }
/* The title's link covers the entry: a click, a middle-click or a tab anywhere in it goes to the page. It stays
   above a stepped-back drawing (opacity paints that above it otherwise). Its focus ring lies on the entry's
   hairlines and reaches a little past the column on each side. */
.work h2 a::after { content: ""; position: absolute; z-index: 1; inset: 0 -0.75rem; border-radius: 0.5rem; }
.work h2 a:focus-visible { outline: none; }
.work h2 a:focus-visible::after { outline: 2px solid var(--accent); }
.work-go {
  display: inline-block;
  margin-left: 0.35em;
  color: var(--accent);
  font-weight: 400;
  opacity: 0;
  transform: translateX(-0.4em);
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.work-summary { margin: 0.625rem 0 0; font-size: 1rem; line-height: 1.55; color: var(--gray-600); }

.work:is(:hover, :focus-within, .live)::before { transform: none; }
.work:is(:hover, :focus-within, .live) .work-go { opacity: 1; transform: none; }
/* While one entry is alive, the other drawings step back. */
.work-mark { transition: opacity 0.35s ease; }
.works:has(.work:is(:hover, :focus-within, .live)) .work:not(:hover, :focus-within, .live) .work-mark { opacity: 0.4; }

/* The drawings. Shared: quiet lines, nodes that hide the field behind them, and the parts that show only while
   the entry is alive. */
.mk-base { fill: none; stroke: var(--mk-line); stroke-width: 1.25; }
.mk-lane { fill: none; stroke: var(--mk-line); stroke-width: 1; opacity: 0.55; }
.mk-node { fill: var(--page); stroke: var(--mk-line); stroke-width: 1.25; }
.mk-live { opacity: 0; transition: opacity 0.35s ease; }
.work:is(:hover, :focus-within, .live) .mk-live { opacity: 1; }
/* A bright dash that runs once along a wire (the path has pathLength="100"). */
.mk-flow { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 10 120; stroke-dashoffset: 12; }

/* The system map: the phone, the box, the machines, and the agents on their lanes. */
.mk-msg { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.mk-box { fill: var(--mk-soft-2); stroke: var(--accent); stroke-width: 1.5; }
.mk-led { fill: var(--accent-2); }
.mk-agent { fill: var(--accent); }
.mk-agent-2 { fill: var(--accent-2); }

/* The court: the floor, the paint, the hoops and a drawn play. The ball runs the play and the hoop rings. */
.mk-floor { fill: var(--mk-soft); stroke: var(--mk-line); stroke-width: 1.25; }
.mk-paint { fill: var(--mk-soft-2); stroke: var(--mk-line); stroke-width: 1.25; }
.mk-hoop { fill: none; stroke: var(--accent-2); stroke-width: 1.5; }
.mk-play { fill: none; stroke: var(--accent-2); stroke-width: 1.5; stroke-linecap: round; stroke-dasharray: 0.5 4.5; }
.mk-cross { fill: none; stroke: var(--mk-line); stroke-width: 1.5; stroke-linecap: round; }
.mk-player { fill: var(--page); stroke: var(--accent); stroke-width: 1.75; }
.mk-ball { fill: none; stroke: var(--accent-2); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 0.1 200; }
.mk-swish { fill: none; stroke: var(--accent-2); stroke-width: 1.25; transform-box: fill-box; transform-origin: center; }

/* The river: the streams, and the current that runs along them. */
.mk-bank { fill: none; stroke: var(--accent); stroke-width: 1; opacity: 0.35; }
.mk-current { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linecap: round; stroke-dasharray: 2 10; }
.mk-bank-2, .mk-current-2 { stroke: var(--accent-2); }

/* The radar and the pulse: the sweep turns, each find rings as the beam passes, and posts run out on the line. */
.mk-scope { fill: var(--mk-soft); stroke: var(--mk-line); stroke-width: 1.25; }
.mk-sweep { transform-origin: 58px 60px; }
.mk-wedge { fill: var(--accent); opacity: 0.18; }
.mk-beam { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; }
.mk-blip { fill: var(--accent-2); }
.mk-ping { fill: none; stroke: var(--accent-2); stroke-width: 1.25; transform-box: fill-box; transform-origin: center; }
.mk-signal { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mk-end { fill: var(--accent); }
.mk-flow-signal { stroke: var(--accent-2); stroke-width: 3; }

@keyframes mk-flow { from { stroke-dashoffset: 12; } to { stroke-dashoffset: -102; } }
@keyframes mk-slide { 50% { transform: translateX(var(--dx)); } }
@keyframes mk-blink { 50% { opacity: 0.2; } }
@keyframes mk-ball { 0% { stroke-dashoffset: 0; opacity: 0; } 6% { opacity: 1; } 72% { stroke-dashoffset: -100; opacity: 1; } 80%, 100% { stroke-dashoffset: -100; opacity: 0; } }
@keyframes mk-swish { 0%, 72% { transform: none; opacity: 0; } 74% { opacity: 1; } 100% { transform: scale(4); opacity: 0; } }
@keyframes mk-current { to { stroke-dashoffset: -12; } }
@keyframes mk-spin { to { transform: rotate(360deg); } }
@keyframes mk-ping { 0% { transform: none; opacity: 1; } 40%, 100% { transform: scale(4); opacity: 0; } }
.mk-flow { animation: mk-flow 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.mk-flow-signal { animation-duration: 1.3s; }
.mk-agent { animation: mk-slide var(--t, 2.4s) ease-in-out infinite; }
.mk-led { animation: mk-blink 1.4s ease-in-out infinite; }
.mk-ball { animation: mk-ball 2.6s ease-in-out infinite; }
.mk-swish { animation: mk-swish 2.6s ease-out infinite; }
.mk-current { animation: mk-current var(--t, 1.4s) linear infinite; }
.mk-sweep { animation: mk-spin 3s linear infinite; }
.mk-ping { animation: mk-ping 3s ease-out infinite; }
/* At rest a drawing holds still where it is; alive, it runs. */
.work-mark :is(.mk-flow, .mk-agent, .mk-led, .mk-ball, .mk-swish, .mk-current, .mk-sweep, .mk-ping) { animation-play-state: paused; }
.work:is(:hover, :focus-within, .live) .work-mark :is(.mk-flow, .mk-agent, .mk-led, .mk-ball, .mk-swish, .mk-current, .mk-sweep, .mk-ping) { animation-play-state: running; }

/* Phones: the drawing on top at the full width of the column, then the text. */
@media (max-width: 639px) {
  .works { margin-top: 2rem; }
  .work { grid-template-columns: minmax(0, 1fr); row-gap: 1.25rem; padding: 1.75rem 0 2rem; }
  .work h2 { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .work::before, .work-go, .work-mark, .mk-live { transition: none; }
  .work-mark * { animation: none; }
}
