/* ==========================================================
   Activity: /activity, a MOCK of live stats about the site, as a bento of widgets.
   activity.js fills in the numbers; this file is the look.
   Builds on styles.css (tokens, .page, .grid, .tile, .small).
   ========================================================== */

.ac {
  --ac-good: #0fa968;          /* the green for "live" and "good" (deeper than --accent, to show on white) */
  --ac-soft: rgba(15, 169, 104, .14);
  --ac-idle: #d5d5dd;          /* empty tracks and unlit dots */
  /* The three Activity rings (on a tile that's dark in both themes) */
  --ring-1: #fa114f;
  --ring-2: #a6ff00;
  --ring-3: #00d8ff;
  /* The globe's colours: globe.js reads these names */
  --vs-sphere: #e8e8ee;
  --vs-sphere-light: #fcfcfe;
  --vs-rim: #d9d9e1;
  --vs-dot: #9a9aa9;
  --vs-place: var(--ac-good);
  --vs-arc: var(--ac-good);
  --vs-home: #111111;
  --vs-ring: #111111;
  --vs-you: #007aff;
  font-family: var(--font);
}
:root[data-theme="dark"] .ac {
  --ac-good: #2fd08a;
  --ac-soft: rgba(47, 208, 138, .16);
  --ac-idle: #3a3a42;
  --vs-sphere: #111114;
  --vs-sphere-light: #27272e;
  --vs-rim: #35353d;
  --vs-dot: #8b8b9b;
  --vs-home: #ffffff;
  --vs-ring: #ffffff;
  --vs-you: #0a84ff;
}

/* ---------- Header ---------- */
.ac-head { display: flex; flex-direction: column; gap: 12px; max-width: 640px; margin-bottom: 28px; }
.ac-app { display: flex; align-items: center; gap: 8px; font-family: var(--font-system); font-size: 13px; font-weight: 600; color: var(--muted); }
.ac-heading { font-size: clamp(28px, 4vw, 40px); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.ac-lede { font-size: 17px; line-height: 1.55; color: var(--body-text); }
.ac-sample {
  margin-left: 6px;
  padding: 3px 9px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* The green "live" dot, with a slow ring breathing out of it */
.ac-dot { position: relative; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--ac-good); }
.ac-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: ac-breathe 2.4s ease-out infinite;
}
@keyframes ac-breathe {
  from { transform: scale(1); opacity: .6; }
  to { transform: scale(3.2); opacity: 0; }
}

/* ---------- The grid ---------- */
/* Same four columns as the homepage. Which tiles are bigger: */
.ac-live   { grid-column: span 2; grid-row: span 2; }
.ac-vitals { grid-row: span 2; }
.ac-lh, .ac-pulse, .ac-bots { grid-column: span 2; }

/* Tiles rise in, one after another, as they scroll into view (activity.js adds .is-in) */
.ac-js .ac-grid .tile {
  opacity: 0;
  transform: translateY(16px) scale(.985);
  transition: opacity .5s ease, transform var(--speed-arrive) var(--ease-arrive);
  transition-delay: var(--stagger, 0s);
}
.ac-js .ac-grid .tile.is-in { opacity: 1; transform: none; }

/* ---------- Shared bits inside tiles ---------- */
.ac-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; line-height: 20px; color: var(--muted); }
.ac-stat { display: flex; align-items: baseline; gap: 4px; font-size: clamp(40px, 3.8vw, 54px); font-weight: 600; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ac-stat small { font-size: .42em; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.ac-sub { font-size: 13px; line-height: 1.4; color: var(--muted); }
.ac-sub strong { color: var(--text); font-weight: 600; }
.ac-foot { margin-top: auto; font-size: 12px; line-height: 1.4; color: var(--muted); }
.ac-foot strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* A row of: name, bar, number. The bar grows from nothing when the tile arrives. */
.ac-waterfall li,
.ac-bot-list li,
.ac-region-list li { --share: 0; display: grid; align-items: center; gap: 10px; font-size: 13px; }
.ac-waterfall i,
.ac-bot-list i,
.ac-region-list i { position: relative; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ac-bot-list i::after,
.ac-region-list i::after {
  content: "";
  position: absolute;
  inset: 0;
  width: calc(var(--share) * 1%);
  border-radius: 3px;
  background: var(--ac-good);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1s var(--ease-arrive) .25s;
}
.ac-bot-list.is-lit i::after,
.ac-region-list.is-lit i::after { transform: none; }
.ac-waterfall b,
.ac-bot-list b,
.ac-region-list b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- 1. Live ---------- */
.ac-live { gap: 0; }
/* Everything but the globe sits above it and lets drags through to it */
.ac-live > :not(.ac-globe) { position: relative; z-index: 1; pointer-events: none; }
.ac-hero { display: flex; align-items: flex-end; gap: 14px; margin-top: 18px; }
.ac-hero-number { font-size: clamp(88px, 10vw, 148px); font-weight: 600; line-height: .82; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.ac-hero-number.is-tick { animation: ac-tick .5s var(--ease-spring); }
@keyframes ac-tick {
  from { transform: translateY(18%); opacity: .2; }
}
.ac-hero-unit { padding-bottom: 4px; font-size: 17px; font-weight: 600; line-height: 1.2; color: var(--muted); }
.ac-counts { display: flex; gap: 28px; margin-top: 26px; }
.ac-counts dt { font-size: 13px; color: var(--muted); }
.ac-counts dd { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

/* The globe: big, and half off the tile's corner */
.ac-globe { position: absolute; right: -15%; bottom: -24%; width: 92%; aspect-ratio: 1; }
.ac-globe canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
.ac-globe canvas.is-dragging { cursor: grabbing; }

/* The latest page views, newest on top */
.ac-feed { display: flex; flex-direction: column; align-items: flex-start; margin-top: auto; }
.ac-feed li {
  display: flex;
  align-items: center;
  gap: 8px;
  max-height: 44px;
  margin-top: 8px;
  padding: 8px 14px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 8px 18px -12px var(--shadow);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  animation: ac-feed-in .55s var(--ease-arrive);
}
.ac-feed li:nth-child(2) { opacity: .8; }
.ac-feed li:nth-child(3) { opacity: .55; }
.ac-feed li:nth-child(n+4) { opacity: .3; }
.ac-feed li.is-leaving { max-height: 0; margin-top: 0; padding-block: 0; border-width: 0; opacity: 0; transition: all .4s ease; }
.ac-feed strong { font-weight: 600; }
.ac-feed time { color: var(--muted); }
.ac-feed-flag { font-size: 16px; line-height: 1; }
@keyframes ac-feed-in {
  from { max-height: 0; margin-top: 0; padding-block: 0; opacity: 0; transform: translateX(-12px); }
}

/* ---------- 2. Web Vitals rings (dark in both themes) ---------- */
.ac-vitals { background: #0b0b0d; color: #fff; box-shadow: inset 0 0 0 1px var(--dark-tile-edge); gap: 18px; }
.ac-vitals .ac-label,
.ac-vitals .ac-foot { color: #9d9da6; }
.ac-rings { align-self: center; width: min(100%, 250px); margin: 6px 0; overflow: visible; }
.ac-ring-track { opacity: .22; }
.ac-ring,
.ac-gauge {
  --fill: 0;   /* activity.js sets the real share; the ring sweeps round to it */
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 1.8s var(--ease-arrive) calc(.3s + var(--wait, 0s));
}
.is-in .ac-ring,
.is-in .ac-gauge { stroke-dashoffset: calc(100 - var(--fill)); }
.ac-vital-list { display: flex; flex-direction: column; gap: 12px; }
.ac-vital-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; padding-left: 14px; border-left: 3px solid var(--c); }
.ac-vital-name { font-size: 15px; font-weight: 600; }
.ac-vital-what { grid-column: 1; font-size: 12px; color: #9d9da6; }
.ac-vital-list strong { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 20px; font-weight: 600; color: var(--c); font-variant-numeric: tabular-nums; }

/* ---------- 3. Your visit ---------- */
.ac-you, .ac-edge { gap: 8px; }
.ac-waterfall { display: flex; flex-direction: column; gap: 7px; margin-top: auto; }
.ac-waterfall li { grid-template-columns: 62px minmax(0, 1fr) 56px; color: var(--muted); }
.ac-waterfall b { color: var(--text); }
/* Each step's bar starts where the one before ended (activity.js sets --from and --to) */
.ac-waterfall i::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: calc(var(--from, 0) * 1%);
  width: calc((var(--to, 0) - var(--from, 0)) * 1%);
  min-width: 4px;
  border-radius: 3px;
  background: var(--apple-blue);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .5s var(--ease-arrive) var(--wait, 0s);
}
.is-in .ac-waterfall i::after { transform: none; }

/* ---------- 4. Served nearby: a hundred dots ---------- */
.ac-dots { display: grid; grid-template-columns: repeat(20, 1fr); gap: 4px; margin-top: auto; }
.ac-dots i { aspect-ratio: 1; border-radius: 50%; background: var(--ac-idle); transition: background .4s ease var(--wait, 0s), transform .4s var(--ease-spring) var(--wait, 0s); transform: scale(.4); }
.ac-dots.is-lit i { transform: none; }
.ac-dots.is-lit i.is-hit { background: var(--ac-good); }
.ac-dots i.is-ping { animation: ac-ping .7s ease-out; }
@keyframes ac-ping {
  30% { transform: scale(1.7); box-shadow: 0 0 0 4px var(--ac-soft); }
}
.ac-edge .ac-foot { margin-top: 6px; }

/* ---------- 5. Lighthouse ---------- */
.ac-gauges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: auto 0; }
.ac-gauges li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.ac-gauges svg { width: min(100%, 104px); transform: rotate(-90deg); fill: none; stroke-width: 7; stroke-linecap: round; }
.ac-gauge-track { stroke: var(--ac-soft); }
.ac-gauge { stroke: var(--ac-good); }
/* The score sits in the middle of its dial */
.ac-gauges strong { position: absolute; top: 0; left: 50%; width: min(100%, 104px); aspect-ratio: 1; display: grid; place-items: center; transform: translateX(-50%); font-size: clamp(22px, 2.2vw, 30px); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ac-gauges span { font-size: 13px; font-weight: 500; color: var(--muted); }
.ac-lh .ac-foot { margin-top: 0; }

/* ---------- 6. Response time ---------- */
.ac-pulse { gap: 6px; padding-bottom: 0; }
.ac-pulse-top { display: flex; justify-content: space-between; gap: 16px; }
.ac-pulse-stats { display: flex; gap: 24px; text-align: right; }
.ac-pulse-stats dt { font-size: 12px; color: var(--muted); }
.ac-pulse-stats dd { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
/* The line runs edge to edge along the bottom of the tile */
.ac-line { flex: 1; min-height: 0; width: calc(100% + 2 * var(--tile-pad)); margin: 0 calc(-1 * var(--tile-pad)); }

/* ---------- 7. People and robots ---------- */
.ac-bots { gap: 16px; }
.ac-split { display: flex; gap: 4px; height: 56px; font-size: 13px; }
.ac-split span { display: flex; align-items: center; gap: 5px; padding: 0 14px; border-radius: 12px; white-space: nowrap; overflow: hidden; }
.ac-split b { font-weight: 600; }
.ac-split-people { --share: 0; flex: 0 0 0%; background: var(--ac-good); color: #04130c; transition: flex-basis 1.2s var(--ease-arrive) .2s; }
.is-in .ac-split-people { flex-basis: calc(var(--share) * 1%); }
.ac-split-bots { flex: 1; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.ac-split-bots b { color: var(--text); }
.ac-bot-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; margin-top: auto; }
.ac-bot-list li { grid-template-columns: 96px minmax(0, 1fr) 34px; }
.ac-bot-list i::after { background: var(--apple-purple); }

/* ---------- 8. Around the world ---------- */
.ac-region-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.ac-region-list li { grid-template-columns: 78px minmax(0, 1fr) 40px; }
.ac-region-list i::after { background: var(--apple-orange); }

/* ---------- 9. Last published ---------- */
.ac-ship { gap: 8px; }
.ac-timer { font-size: clamp(22px, 2.1vw, 28px); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ac-ship-facts { display: flex; gap: 20px; margin-top: auto; }
.ac-ship-facts dt { font-size: 12px; color: var(--muted); }
.ac-ship-facts dd { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 10. What it took to build (full width) ---------- */
.ac-built { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) auto; align-items: center; gap: 24px 56px; }
.ac-built-main { display: flex; flex-direction: column; gap: 10px; }
.ac-built-number { font-size: clamp(38px, 5.4vw, 84px); letter-spacing: -0.045em; }
.ac-built-number { flex-wrap: wrap; row-gap: 6px; }
.ac-built-number small { font-size: .6em; }
.ac-built-number .ac-built-unit { margin-left: .12em; font-size: .38em; letter-spacing: -0.01em; }
.ac-built-facts { display: grid; grid-template-columns: repeat(2, auto); justify-content: start; gap: 16px 48px; }
.ac-built-facts dt { font-size: 12px; color: var(--muted); }
.ac-built-facts dd { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ac-built-map { display: flex; flex-direction: column; gap: 10px; width: fit-content; }
/* A square per day, a column per week (Monday at the top), darker for more commits */
.ac-days { display: grid; grid-template-rows: repeat(7, 18px); grid-auto-columns: 18px; grid-auto-flow: column; gap: 4px; }
.ac-days i { border-radius: 5px; background: var(--ac-idle); opacity: .45; transform: scale(.3); transition: transform .45s var(--ease-spring) var(--wait, 0s), background .45s ease var(--wait, 0s), opacity .45s ease var(--wait, 0s); }
.ac-days.is-lit i { transform: none; }
.ac-days.is-lit i[data-level] { background: var(--ac-good); }
.ac-days.is-lit i[data-level="1"] { opacity: .35; }
.ac-days.is-lit i[data-level="2"] { opacity: .65; }
.ac-days.is-lit i[data-level="3"] { opacity: 1; }
.ac-days-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

.ac-note { max-width: 720px; margin-top: 20px; padding: 0 4px; }

/* ---------- Two columns (tablets and small laptops) ---------- */
@media (max-width: 1180px) {
  .ac-vitals { grid-column: span 2; grid-row: auto; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 28px; }
  .ac-vitals .ac-label, .ac-vitals .ac-foot { grid-column: 1 / -1; }
  .ac-rings { width: 200px; }
  .ac-live { min-height: 600px; }
  .ac-built { grid-template-columns: minmax(0, 1fr) auto; }
  .ac-built-main { grid-column: 1 / -1; }
}

/* ---------- Phones: one tile per row ---------- */
@media (max-width: 640px) {
  .ac-grid .tile { grid-column: 1 / -1; grid-row: auto; --tile-pad: 20px; padding: 20px; }
  .ac-live { min-height: 540px; }
  .ac-globe { right: -30%; bottom: -16%; width: 120%; }
  .ac-counts { gap: 20px; }
  .ac-vitals { display: flex; }
  .ac-rings { width: min(100%, 220px); }
  .ac-gauges { gap: 6px; }
  .ac-gauges span { font-size: 11px; }
  .ac-pulse { min-height: 260px; padding-bottom: 0; }
  .ac-bot-list { grid-template-columns: minmax(0, 1fr); }
  .ac-edge, .ac-you, .ac-world, .ac-ship { min-height: 230px; }
  .ac-built { grid-template-columns: minmax(0, 1fr); }
  .ac-built-facts { gap: 14px 40px; }
  .ac-built-number { font-size: min(10.4vw, 44px); }
}

@media (prefers-reduced-motion: reduce) {
  .ac-dot::after { animation: none; opacity: 0; }
}

/* A number that's just changed (a refresh) gives a small hop */
.ac [data-live].is-tick { display: inline-block; animation: ac-tick .5s var(--ease-spring); }
.ac-sample[hidden] { display: none; }

/* Robots: a thin bar split in two (purple: robots that say what they are; green: everyone else),
   with the two shares written underneath. (The shares are lopsided, so they can't sit inside.) */
.ac-split { height: 14px; gap: 3px; font-size: 0; }
.ac-split span { padding: 0; border-radius: 7px; }
.ac-split-bots { --share: 0; flex: 0 0 calc(var(--share) * 1%); min-width: 8px; background: var(--apple-purple); box-shadow: none; }
.ac-split-people { flex: 1 1 0; background: var(--ac-good); transition: none; }
.ac-split-key { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: -6px; font-size: 13px; color: var(--muted); }
.ac-split-key b { margin-right: 3px; font-weight: 600; color: var(--text); }
.ac-split-key-bots::before,
.ac-split-key-people::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--apple-purple); }
.ac-split-key-people::before { background: var(--ac-good); }
