/* ============================================================
   Aventurine — the Aventurine Manage page's feature section
   Load after css/budget-tiles.css.

   Features: one row per feature, copy on one side and a small demo on
   the other, swapping sides down the page. Each demo is a window of its
   own: the app's surface with a hairline edge and the soft lift the hero's
   app window had (css/hero-ledger.css, .ledger-window). Each window holds
   a working replica of one page of the app (css/feature-demos.css); the
   Reports one draws its Sankey with js/feature-sankey.js.
   The copy is first in the markup. Below 900px the rows stack in that order.

   How it works: one row of three drawings joined by arrows (.how-flow).
   ============================================================ */

/* ---------- section headings ----------
   Every section heading on this page takes the home page's size
   (css/home.css, .home-faq and .winning), not sections.css's larger
   default. Only aventurine-manage.html loads this file, so the rule stays on this page. */
.sec-head h2 { font-size: clamp(2rem, 3.6vw, 3rem); text-wrap: balance }

/* ---------- the features ---------- */
.features .sec-head { max-width: none; margin-bottom: 4rem; text-align: center }

.fx-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: clamp(2rem, 6vw, 5rem);
}
.fx-row + .fx-row { margin-top: clamp(4rem, 9vw, 6rem) }
/* demo on the left, copy on the right */
@media (min-width: 901px) {
  .fx-row--flip .fx-frame { order: -1 }
}

.fx-copy .fx-eyebrow {
  margin: 0 0 12px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.fx-copy h3 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); line-height: 1.15; text-wrap: balance }
.fx-copy p {
  max-width: 44ch;
  margin-top: 16px;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-muted);
}

/* The frame holds the window's size and place: 4:3, the shape the replicas
   are drawn at. The panel is the window and fills it. The shadow is on the
   panel and the frame does not clip, so the lift reaches past the edge. */
.fx-frame {
  position: relative;
  width: 100%;
  max-width: 560px;
  justify-self: center;
  aspect-ratio: 4 / 3;
}
.fx-panel {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--color-aventurine-900) 20%, transparent);
  border-radius: var(--radius-lg);
  background: var(--app-surface);
  box-shadow: var(--shadow-frame), 0 24px 48px -32px rgb(0 0 0 / .45);
  /* the replicas size themselves from the panel's width (feature-demos.css) */
  container-type: inline-size;
}
.fx-panel img { display: block; width: 100%; height: 100%; object-fit: cover }

@media (max-width: 900px) {
  .fx-row { grid-template-columns: minmax(0, 1fr); gap: 32px }
}

/* ---------- how it works ----------
   One row: the bank, the file it exports, and Aventurine Manage, with a labelled
   arrow between each. Each drawing and its name sit in a subgrid, so the
   first row is exactly as tall as the drawings and the arrows centre on
   them. Below 560px the row becomes a column and the arrows point down. */
.how-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: clamp(16px, 3vw, 32px);
  row-gap: 16px;
  max-width: 880px;
  margin: 0 auto;
}
.how-node {
  grid-row: 1 / span 2;
  display: grid;
  grid-template-rows: subgrid;
  justify-items: center;
  text-align: center;
}
.how-art { display: block; width: 100%; max-width: 160px; height: auto }
.how-name { font-weight: 600; color: var(--text); text-wrap: balance }
.how-link {
  grid-row: 1;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  color: var(--accent);
}
.how-verb {
  align-self: end;
  margin-bottom: 8px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.how-arrow { display: block; width: clamp(32px, 5vw, 48px); height: auto }

@media (max-width: 560px) {
  .how-flow { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; row-gap: 12px }
  .how-node { grid-row: auto; grid-template-rows: auto auto; row-gap: 12px }
  .how-art { max-width: 120px }
  .how-link { grid-row: auto; grid-template-rows: auto auto; padding: 4px 0 }
  .how-verb { align-self: auto; margin-bottom: 4px }
  .how-arrow { width: 32px; transform: rotate(90deg) }
}

/* ---------- making the switch ----------
   Two columns: the header and intro on the left, and on the right one stage
   on the tan ground. On the stage the Aventurine logo sits in the middle and
   the five places people come from float round it, a dotted line to each
   with a file travelling in along it. Closer in, the seven file types it
   reads float on a ring of their own, each on a plain dotted line to the
   logo. The picture says "from anywhere, in any of these, into one place".
   Below 1000px the two columns stack, header first.

   The stage keeps one shape, 640 x 470, so the drawing (.mg-art, one SVG in
   that box) and the avatars (placed in percentages of it) stay lined up at
   any width. Each avatar is the middle of its line and sits on one of five
   evenly spaced points of a circle round the hub (a pentagon, the first
   point straight above it), so each is the same distance from the logo.
   The file types sit on a smaller circle (radius 130 against the avatars'
   190), at angles picked to fall in the gaps between the five lanes and
   clear of the name pills. Under 500px that would be too tight for the
   names, so the stage falls back to a grid of the five with one dotted line
   down to the hub, and the file types to a row under it. The
   avatars are the platforms' logos (Your bank, which has none, takes a tinted
   glyph in the app's merchant colours) and the names and file types are
   white Ant tags, so the section reads as part of the same system as the
   replicas above it. */
.mg-section { padding: clamp(3.5rem, 8vh, 5rem) 0 }

.mg-layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 5vw, 64px);
  align-items: center;
}

/* the header, left-aligned in its column. Comes after .flow .sec-head, whose
   width and bottom margin it undoes. */
.sec-head.mg-head { max-width: none; margin: 0; text-align: left }
/* the second sentence breaks as a whole or not at all */
.mg-nowrap { white-space: nowrap }

/* the supported types: Ant's tags, in white like the names, on an inner ring
   round the hub. Like the avatars, --x and --y are each tag's middle in
   percent of the stage. */
.mg-types { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none }
.mg-type { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%) }
.mg-type .mg-tag { display: block; animation: mg-float var(--t) ease-in-out var(--d) infinite }
.mg-tag {
  padding: .45em .7em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  color: var(--text);
  font: 600 clamp(.62rem, 1.75cqw, .7rem)/1 'IBM Plex Mono', monospace;
  letter-spacing: .05em;
}

/* the stage's container: the narrow layout below is chosen by its width,
   not the window's, since the stage is a column in one layout and the full
   width in the other */
.mg-stage-wrap { container: mgstage / inline-size }
.mg-stage {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 640 / 470;
  margin: 0 auto;
}
/* a dot grid behind everything, fading out toward the edges */
.mg-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, color-mix(in srgb, var(--text) 38%, transparent) 1.2px, transparent 1.9px) 0 0 / 22px 22px;
  -webkit-mask-image: radial-gradient(closest-side, #000 40%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 40%, transparent 100%);
}

/* ---------- the drawing ---------- */
.mg-art { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible }
.mg-lane path {
  fill: none;
  stroke: color-mix(in srgb, var(--text) 38%, transparent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 0.1 7;
}
/* The file in flight. Each lane's path is 100 long (pathLength), the dash is
   7 of it and the gap the other 93, so exactly one dash is on the line and
   sliding the offset a whole period (100) moves it from the avatar to the
   hub and starts the next one. It goes in the avatar's own hue. */
.mg-lane .mg-comet {
  stroke: var(--hue);
  stroke-width: 3.2;
  stroke-dasharray: 7 93;
  animation: mg-flow 4.8s linear var(--delay) infinite;
}
@keyframes mg-flow { to { stroke-dashoffset: -100 } }
/* the file types' links: the same dots, a little fainter, with nothing
   travelling on them */
.mg-links path {
  fill: none;
  stroke: color-mix(in srgb, var(--text) 28%, transparent);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-dasharray: 0.1 6;
}

/* ---------- the origins ---------- */
.mg-sources { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none }
/* --x and --y are the avatar's middle, in percent of the stage. The item is
   as wide as the longest name needs and is pulled back by half of it and by
   half the avatar. */
.mg-src { position: absolute; left: var(--x); top: var(--y); width: 112px; margin: -28px 0 0 -56px }
.mg-float {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: mg-float var(--t) ease-in-out var(--d) infinite;
}
@keyframes mg-float { 50% { transform: translateY(-7px) } }

/* an Ant avatar: a logo, or initials or an icon on a pale hue in its deep one */
.mg-av {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--av-bg);
  color: var(--av-ink);
  font: 600 18px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  letter-spacing: .02em;
  box-shadow: 0 0 0 4px var(--white), 0 14px 24px -10px color-mix(in srgb, var(--color-aventurine-900) 45%, transparent);
}
.mg-av svg { width: 26px; height: 26px; fill: currentColor }
.mg-av--cyan    { --av-bg: #b5f5ec; --av-ink: #006d75 }
.mg-av--monarch { --av-bg: #ff692d }   /* Monarch's orange, its mark in white on it */
/* a logo: a mark on white sits inside the circle with room round it, and one
   that is already a coloured square (--bleed) fills it, as the app's merchant
   icons do */
.mg-av--logo { background: var(--white); box-shadow: 0 0 0 4px var(--white), inset 0 0 0 1px var(--border), 0 14px 24px -10px color-mix(in srgb, var(--color-aventurine-900) 45%, transparent) }
.mg-av img { display: block; width: 100%; height: 100%; padding: 13px; object-fit: contain }
.mg-av--bleed img { padding: 0; border-radius: 50%; object-fit: cover }

.mg-name {
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
  font: 600 .78rem/1.5 'Manrope', sans-serif;
  white-space: nowrap;
}

/* ---------- the hub ----------
   The Aventurine logo, twice the avatars' size, with the same white ring. */
/* The hub and the file types shrink with the stage once it is under its full
   640px (17.5cqw is 112px there), so the ring round the logo keeps its room;
   the avatars and names keep their size. */
.mg-hub { position: absolute; left: 50%; top: 50%; width: min(112px, 17.5cqw); aspect-ratio: 1; transform: translate(-50%, -50%) }
.mg-logo {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 9.4%;
  box-shadow: 0 0 0 6px var(--white), 0 2px 8px rgb(0 0 0 / .06), 0 24px 40px -22px rgb(0 0 0 / .5);
}

@keyframes mg-drop { to { background-position: 0 36px, 50% 0 } }

/* ---------- narrower ---------- */
@media (max-width: 1000px) {
  .mg-layout { grid-template-columns: minmax(0, 1fr); gap: 2.5rem }
  .sec-head.mg-head { max-width: 56ch; margin: 0 auto; text-align: center }
}

/* The circle is too tight for five names: they fall into rows of three and two,
   a dotted bracket under them and one line, a file running down it, into the
   hub below. The grid is six columns wide so the two in the second row can
   sit centred, each across a pair of them. */
@container mgstage (max-width: 499px) {
  .mg-stage { aspect-ratio: auto; max-width: 420px }
  .mg-art { display: none }
  .mg-sources { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 22px 6px; padding-bottom: 22px }
  .mg-src { position: static; grid-column: span 2; width: auto; margin: 0 }
  .mg-src:nth-child(4) { grid-column: 2 / span 2 }
  .mg-src:nth-child(5) { grid-column: 4 / span 2 }
  /* a dotted bracket under the grid, from the middle of the first of the
     bottom pair to the middle of the second, so the line down to the hub
     reads as coming from all five */
  .mg-sources::after {
    content: "";
    position: absolute;
    left: calc(100% / 3);
    right: calc(100% / 3);
    bottom: 0;
    height: 22px;
    border: 2px dotted color-mix(in srgb, var(--text) 38%, transparent);
    border-top: 0;
    border-radius: 0 0 10px 10px;
  }
  .mg-hub { position: relative; left: auto; top: auto; width: 112px; margin: 36px auto 0; transform: none }
  /* the file types, a centred row under the hub */
  .mg-types { position: static; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 24px }
  .mg-type { position: static; transform: none }
  .mg-tag { font-size: .7rem }
  .mg-hub::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 100%;
    width: 4px;
    height: 36px;
    margin-left: -2px;
    background:
      linear-gradient(var(--accent), var(--accent)) 0 -14px / 4px 14px no-repeat,
      radial-gradient(circle, color-mix(in srgb, var(--text) 40%, transparent) 1px, transparent 1.6px) 50% 0 / 4px 8px repeat-y;
    animation: mg-drop 2.4s linear infinite;
  }
}

/* held still: the avatars rest and the files stay where they start (under
   the avatars). */
@media (prefers-reduced-motion: reduce) {
  .mg-float, .mg-type .mg-tag, .mg-lane .mg-comet, .mg-hub::before { animation: none }
}
