/* ============================================================
   Aventurine — the ledger hero (aventurine-manage.html)
   Load after css/sections.css.

   The first site's product hero (centred name, headline, lead, button over
   a band, with the app straddling the band's lower edge) with the
   screenshot replaced by a small working replica of the app. A month's
   bank export prints into the Transactions table row by row; a scan line
   runs down the rows and each gets its category pill as the line passes;
   then the Spending card beside it draws its bars and the month's totals.

   The replica wears the app's own palette (the --app-* tokens in
   css/base.css, each the resolved value of an app token), so it matches
   the screenshots further down the page: tinted category pills, spending
   in red and income in green, as the app shows them.

   It is a real <table> and a real list of values, so it reads the same with
   styles off, to a screen reader, and with reduced motion: every animation
   starts from hidden and fills `both`, and with motion reduced
   sections.css's blanket rule leaves the end state. CSS only: nothing runs
   after the last bar lands.

   Hovering a bar marks its rows and hovering a row marks its bar, paired
   by data-cat (written out per category near the end).

   The timeline, all in one place (the window itself rises in at 0.28s):
     rows    --t-rows + i x 60ms               i = row, 0-7
     scan    --t-scan, --scan-row per row      crosses row i at t-scan + (i + .5) x scan-row
     pills   as the scan crosses their row
     bars    --t-bars + j x 80ms, each value with its bar
     totals  --t-totals
   ============================================================ */

.ledger-hero {
  --overhang: clamp(140px, 20vw, 240px);
  --t-rows: .75s;
  --t-scan: 1.6s;
  --scan-row: .24s;
  --t-bars: 3.65s;
  --t-totals: 4.3s;
  position: relative;
  isolation: isolate;
  padding: clamp(4.5rem,11vh,7rem) 0 0;
  color: var(--surface);
}
/* the band: Aventurine's dark stone ground with the screen lit from behind,
   as on its band on the home page. It stops --overhang short of the bottom,
   so the replica's lower part sits on the page. */
.ledger-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 var(--overhang) 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 60% 55% at 50% 100%,
      color-mix(in srgb, var(--color-accent-700) 45%, transparent), transparent 72%),
    radial-gradient(ellipse 100% 90% at 30% 0%,
      var(--hero-ground) 0%, var(--color-aventurine-950) 85%);
}

.ledger-hero-copy { text-align: center }
.ledger-hero h1 { font-size: clamp(2.6rem,6vw,4.4rem); color: var(--color-aventurine-50) }
.ledger-hero .lead { margin: 24px auto 32px; font-size: 1.12rem; color: var(--text-on-dark-muted) }
.ledger-hero .status-pill {
  border-color: color-mix(in srgb, var(--accent-soft) 40%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 12%, transparent);
  color: var(--accent-soft);
}
/* as on the first site's hero for this same copy: one line each once there is room */
@media (min-width: 700px) {
  .ledger-hero h1,
  .ledger-hero .lead { white-space: nowrap }
}

.ledger-hero-copy > * { animation: heroUp .65s cubic-bezier(.22,1,.36,1) both }
.ledger-hero-copy > *:nth-child(2) { animation-delay: .07s }
.ledger-hero-copy > *:nth-child(3) { animation-delay: .14s }
.ledger-hero-copy > *:nth-child(4) { animation-delay: .21s }

/* ---------- the window ---------- */
.ledger { margin-top: clamp(3rem,8vh,4.5rem); min-width: 0; animation: heroUp .8s cubic-bezier(.22,1,.36,1) .28s both }
.ledger-window {
  overflow: hidden;
  background: var(--app-bg);
  border: 1px solid color-mix(in srgb, var(--color-aventurine-900) 20%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-frame), 0 24px 48px -32px rgb(0 0 0 / .45);
  color: var(--app-text);
  text-align: left;
}
.ledger-titlebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  font-size: .8rem;
  color: var(--app-text-2);
  background: color-mix(in srgb, var(--app-text) 7%, var(--app-bg));
}
.ledger-titlebar img { width: 18px; height: 18px; border-radius: 4px }
.ledger-titlebar .ledger-controls { justify-self: end; display: flex; gap: 14px }
.ledger-titlebar .ledger-controls svg { width: 10px; height: 10px; stroke: var(--app-text-2); stroke-width: 1.4; fill: none }

.ledger-panes {
  display: grid;
  grid-template-columns: minmax(0,1fr) 340px;
  gap: 14px;
  padding: 14px;
}
.ledger-card {
  min-width: 0;
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.ledger-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}
.ledger-card-title {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--app-text-2);
}
.ledger-file {
  overflow: hidden;
  font-family: 'IBM Plex Mono', monospace;
  font-size: .76rem;
  color: var(--app-text-3);
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- the table ---------- */
.ledger-body { position: relative; overflow: hidden }
.ledger-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .84rem }
.ledger-table th {
  height: 36px;
  padding: 0 12px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
  color: var(--app-text-3);
  border-top: 1px solid var(--app-line);
  border-bottom: 1px solid var(--app-line);
}
.ledger-table td {
  height: 44px;
  padding: 0 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-bottom: 1px solid color-mix(in srgb, var(--app-line) 60%, transparent);
  transition: background .15s ease;
}
.ledger-table tr:last-child td { border-bottom: 0 }
.ledger-table .c-date { width: 112px; color: var(--app-text-2) }
.ledger-table .c-cat { width: 168px }
.ledger-table .c-amt { width: 112px; text-align: right; font-variant-numeric: tabular-nums }
.ledger-table td.c-amt { color: var(--app-red); font-weight: 500 }
.ledger-table tr.is-income td.c-amt { color: var(--app-green) }

/* merchant initials, as the app shows them beside each description */
.ledger-av {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 10px;
  vertical-align: middle;
  border-radius: 50%;
  font-size: .6rem;
  font-weight: 700;
  color: var(--app-text-2);
  background: color-mix(in srgb, var(--app-accent) 16%, var(--app-surface));
}

.ledger-table tbody tr {
  animation: ledger-row .4s ease both;
  animation-delay: calc(var(--t-rows) + var(--i) * 60ms);
}
@keyframes ledger-row { from { opacity: 0; transform: translateY(6px) } }

/* the category pill: arrives on an accent ring, settles to its tint */
.cat {
  display: inline-block;
  max-width: 100%;
  padding: 3px 10px;
  overflow: hidden;
  vertical-align: middle;
  border-radius: var(--radius-pill);
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--app-red);
  background: color-mix(in srgb, var(--app-red) 11%, var(--app-surface));
  animation: ledger-pill .55s ease both;
  animation-delay: calc(var(--t-scan) + (var(--i) + .5) * var(--scan-row));
}
.is-income .cat { color: var(--app-green); background: color-mix(in srgb, var(--app-green) 12%, var(--app-surface)) }
@keyframes ledger-pill {
  0%   { opacity: 0; transform: scale(.85); box-shadow: 0 0 0 0 color-mix(in srgb, var(--app-accent) 50%, transparent) }
  45%  { opacity: 1; transform: scale(1.04); box-shadow: 0 0 0 4px color-mix(in srgb, var(--app-accent) 22%, transparent) }
  100% { box-shadow: 0 0 0 0 transparent }
}

/* the scan line: one element the height of the rows with its top edge drawn
   as the line, moved down its own height; the wash trails above it */
.ledger-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 36px;
  bottom: 0;
  pointer-events: none;
  opacity: 0;
  animation: ledger-scan calc(var(--scan-row) * 8) linear var(--t-scan) both;
}
.ledger-scan::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  height: 2px;
  background: var(--app-accent);
  box-shadow: 0 0 12px 1px color-mix(in srgb, var(--app-accent) 70%, transparent);
}
.ledger-scan::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 44px;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--app-accent) 12%, transparent));
}
@keyframes ledger-scan {
  0%   { opacity: 0; transform: translateY(0) }
  3%   { opacity: 1 }
  96%  { opacity: 1 }
  100% { opacity: 0; transform: translateY(100%) }
}

/* ---------- the Spending card ---------- */
.ledger-side { display: flex; flex-direction: column }
.bars { list-style: none; padding: 4px 16px 0 }
.bars li {
  display: grid;
  grid-template-columns: 112px minmax(0,1fr) 72px;
  align-items: center;
  gap: 10px;
  height: 30px;
  font-size: .78rem;
  color: var(--app-text-2);
}
.bar-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis }
.bar-track { height: 100%; display: flex; align-items: center; border-left: 1px solid var(--app-line) }
/* one series: the accent, square at the baseline, rounded at the value */
.bar {
  width: calc(var(--v) * 100%);
  height: 10px;
  border-radius: 0 4px 4px 0;
  background: var(--app-chart-1);
  transform-origin: left;
  animation: ledger-bar .7s cubic-bezier(.22,1,.36,1) both;
  animation-delay: calc(var(--t-bars) + var(--j) * 80ms);
  transition: background .15s ease;
}
@keyframes ledger-bar { from { transform: scaleX(0) } }
.bar-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--app-text);
  animation: ledger-fade .4s ease both;
  animation-delay: calc(var(--t-bars) + .1s + var(--j) * 80ms);
}

.ledger-totals {
  margin: auto 16px 0;
  padding: 6px 0 10px;
  animation: ledger-fade .5s ease both var(--t-totals);
}
/* one row per total, label left and value right, so a long figure never
   has to share a narrow column */
.ledger-totals > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--app-line);
}
.ledger-totals dt { font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--app-text-3) }
.ledger-totals dd { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap }
.ledger-totals .is-in dd,
.ledger-totals .is-net dd { color: var(--app-green) }
.ledger-totals .is-out dd { color: var(--app-red) }
@keyframes ledger-fade { from { opacity: 0 } }

.ledger figcaption {
  margin-top: 14px;
  text-align: center;
  font-size: .9rem;
  color: var(--text-muted);
}

/* ---------- linked hover: a bar and its rows ---------- */
.ledger:has(.bars [data-cat="rent"]:hover)   .ledger-table [data-cat="rent"] td,
.ledger:has(.bars [data-cat="auto"]:hover)   .ledger-table [data-cat="auto"] td,
.ledger:has(.bars [data-cat="food"]:hover)   .ledger-table [data-cat="food"] td,
.ledger:has(.bars [data-cat="bills"]:hover)  .ledger-table [data-cat="bills"] td,
.ledger:has(.bars [data-cat="fun"]:hover)    .ledger-table [data-cat="fun"] td,
.ledger:has(.bars [data-cat="health"]:hover) .ledger-table [data-cat="health"] td,
.ledger-table tbody tr:hover td { background: color-mix(in srgb, var(--app-accent) 9%, transparent) }

.ledger:has(.ledger-table [data-cat="rent"]:hover)   .bars [data-cat="rent"] .bar,
.ledger:has(.ledger-table [data-cat="auto"]:hover)   .bars [data-cat="auto"] .bar,
.ledger:has(.ledger-table [data-cat="food"]:hover)   .bars [data-cat="food"] .bar,
.ledger:has(.ledger-table [data-cat="bills"]:hover)  .bars [data-cat="bills"] .bar,
.ledger:has(.ledger-table [data-cat="fun"]:hover)    .bars [data-cat="fun"] .bar,
.ledger:has(.ledger-table [data-cat="health"]:hover) .bars [data-cat="health"] .bar,
.bars li:hover .bar { background: var(--color-accent-800) }

/* ---------- narrower ---------- */
@media (max-width:980px) {
  .ledger-panes { grid-template-columns: minmax(0,1fr) }
  .ledger-totals { margin-top: 12px }
}

/* Phones: no room for four columns. The window reaches into the page's
   gutters, the date and the initials go, and the description wraps (inside a
   word if it must) while the pill and the amount keep their full width, so
   no text is ever cut short. */
@media (max-width:640px) {
  .ledger { margin-inline: -12px }
  .ledger-panes { padding: 6px; gap: 6px }
  .ledger-table .c-date { display: none }
  .ledger-av { display: none }
  .ledger-table th { letter-spacing: .04em }
  .ledger-table th, .ledger-table td { padding: 0 6px }
  .ledger-table th.c-desc { padding-left: 10px }
  .ledger-table td.c-desc {
    padding: 6px 6px 6px 10px;
    font-size: .74rem;
    line-height: 1.35;
    white-space: normal;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }
  .ledger-table .c-cat { width: 132px }
  .ledger-table .c-amt { width: 94px; padding-right: 10px; text-overflow: clip }
  .ledger-table td.c-amt { font-size: .78rem }
  .cat { padding-inline: 7px; font-size: .74rem }
  .bars li { grid-template-columns: 112px minmax(0,1fr) 72px }
}

/* Below a 360px phone the columns no longer fit their content, so the table
   keeps its phone layout and scrolls sideways inside the card. The vertical
   axis stays hidden: the scan line ends below the rows and must not add a
   scroll area of its own. */
@media (max-width:359px) {
  .ledger-body { overflow-x: auto; overflow-y: hidden }
  .ledger-table { min-width: 330px }
}

@media (prefers-reduced-motion:reduce) {
  .ledger-hero-copy > *, .ledger, .ledger-table tbody tr, .cat, .ledger-scan,
  .bar, .bar-val, .ledger-totals { animation: none }
}


/* ---------- the photo ----------
   Aventurine Manage's hero is the photo of the app on a desktop monitor. A
   blurred, darkened, stretched strip of its wall fills the band (the header's ::before) so the
   wall carries on behind the headline, and the sharp photo sits full width
   under the copy, fading in from its top edge so no seam shows. It rises
   behind the button by 7vw, over its own empty wall. */
.tiles .ledger-hero.ledger-hero--shot { padding-bottom: 0; overflow: hidden }
.tiles .ledger-hero.ledger-hero--shot::before {
  background:
    linear-gradient(rgb(0 0 0 / .3), rgb(0 0 0 / .3)),
    url("../assets/images/manage-your-money-mockup.png") center top / 100% 900% no-repeat;
  filter: blur(28px);
  transform: scale(1.15);
}
.ledger-hero--shot .ledger-hero-copy { position: relative; z-index: 1 }
/* The photo spans the viewport up to --hero-photo-max (the image's own
   width) and stops there, so zooming out shrinks it with the rest of the page
   instead of it growing to fill the wider viewport. The rise behind the button
   is a share of the photo's width, so it stops growing with it. */
.ledger-hero--shot { --hero-photo-max: 1536px }
.hero-photo {
  position: relative;
  max-width: var(--hero-photo-max);
  margin: calc(-.07 * min(100vw, var(--hero-photo-max))) auto 0;
  animation: heroUp .8s cubic-bezier(.22,1,.36,1) .28s both;
}
.hero-photo img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 14%);
          mask-image: linear-gradient(to bottom, transparent, #000 14%);
}
/* once the viewport is wider than the photo, its side edges fade into the
   blurred wall behind it so no seam shows */
@media (min-width: 1537px) {
  .hero-photo img {
    -webkit-mask-image:
      linear-gradient(to bottom, transparent, #000 14%),
      linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
    -webkit-mask-composite: source-in;
            mask-image:
      linear-gradient(to bottom, transparent, #000 14%),
      linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
            mask-composite: intersect;
  }
}
@media (prefers-reduced-motion: reduce) { .hero-photo { animation: none } }


/* ---------- the dot wave ----------
   Aventurine Manage's hero: a grid of light grey dots drawn by js/dot-wave.js
   that swell in a slow wave. It fills the band (the header isolates, so
   z-index: -1 puts it above the band's ground and under the copy) and takes
   its dot colour from `color`. It softens behind the headline and lead so the
   copy stays the brightest thing on the band. */
.ledger-hero--dots .dot-wave {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
  color: var(--color-aventurine-300);
  opacity: .55;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 46% 58% at 50% 46%, rgb(0 0 0 / .35) 30%, #000 100%);
          mask-image: radial-gradient(ellipse 46% 58% at 50% 46%, rgb(0 0 0 / .35) 30%, #000 100%);
}
