/* Hero allocation (total left, ring right) and the mobile hero, which must
   stay after every desktop hero rule. */

#hero {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.hero-main { flex: 1 1 auto; min-width: 0; }

.hero-alloc {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-shrink: 0;
  margin-left: auto;
  align-self: stretch;
}

.hero-alloc[hidden] { display: none; }

.donut-sm {
  height: 100%;
  width: auto;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
}

.donut-num {
  font-family: var(--font-display);
  font-size: 33px;
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  fill: var(--text);
}

/* A share ("42%") sits smaller than the count; "100%", "12.5%" and
   "<0.1%" smaller still, so every value clears the hole. */
.donut-num[data-pct] { font-size: 25px; letter-spacing: -0.03em; }
.donut-num[data-pct][data-long] { font-size: 20px; }

.donut-lab {
  font-family: var(--font-ui);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  fill: var(--muted-2);
  transition: fill 0.18s var(--ease);
}

.hero-alloc.has-active .donut-lab { fill: var(--muted); }

/* Ring segments: rounded sectors drawn in hero-alloc.js. Hover / tap
   slides the segment out a few units and dims the others; only transform
   and opacity animate. */
.alloc-seg {
  cursor: pointer;
  transform: translate(0, 0);
  transition: transform 0.22s var(--ease), opacity 0.22s var(--ease);
}

.hero-alloc.has-active .alloc-seg { opacity: 0.28; }

.hero-alloc .alloc-seg.is-active {
  opacity: 1;
  transform: translate(var(--dx, 0px), var(--dy, 0px));
}

#hero-value-num {
  display: inline-block;
  max-width: 100%;
  vertical-align: baseline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-alloc-legend {
  list-style: none;
  margin: 0;
  padding: 0 0.25rem 0 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* Rows keep their natural height. With plain auto rows, Firefox lets the
     max-height cap squeeze every row (the li clip their overflow, so their
     minimum is 0) instead of scrolling: rows overlapped into an unreadable
     smear. */
  grid-auto-rows: max-content;
  gap: 0.4rem;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  color: var(--muted);
}

.hero-alloc-legend li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  overflow: hidden;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: default;
  border-radius: 6px;
  transition: color 0.18s var(--ease), opacity 0.18s var(--ease);
}

.hero-alloc-legend li:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }

.hero-alloc.has-active .hero-alloc-legend li { opacity: 0.45; }
.hero-alloc.has-active .hero-alloc-legend li.is-active { opacity: 1; color: var(--text); }

.hero-alloc-legend li > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-alloc-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 3px;
  flex-shrink: 0;
}

/* The active row is marked by its text and the others dimming. The swatch
   keeps its size: the row clips its overflow (for the … truncation), so a
   grown swatch would be cut off at the row's left edge. */

/* Smoother focus + hover for new interactive rows */
.account-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.trade-block { transition: border-color 0.15s ease, background 0.15s ease; }
.trade-block:hover { border-color: var(--border-strong); }

/* Mobile hero side-by-side rules live in the main 720px block above —
   this slot intentionally holds no hero overrides. */

@media print {
  .hero-alloc { break-inside: avoid; }
  .donut-sm { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ————— Mobile hero: MUST stay after every desktop hero rule in this file.
   Same-specificity later rules win the cascade, so these overrides only
   take effect from down here. Layout: flex row, totals left, one compact
   right column with the ring on top and the legend tucked directly under
   it (never stranded at the box bottom). — */
@media (max-width: 720px) {
  #hero { display: flex; align-items: flex-start; padding: 1.1rem 0.8rem 0.95rem; gap: 0.7rem; }
  .hero-main { flex: 1 1 auto; min-width: 0; }
  .hero-label { font-size: 0.68rem; }
  .hero-value { font-size: clamp(1.35rem, 6.4vw, 1.7rem); margin: 0.35rem 0 0.3rem; }
  /* Net worth: label over figure as on desktop; the lent-out note takes
     its own (always reserved) line in the narrow column. */
  .hero-networth { gap: 0.2rem; margin-top: 0.25rem; }
  .hero-networth-label { font-size: 0.58rem; letter-spacing: 0.12em; }
  .hero-networth-row { flex-wrap: wrap; row-gap: 0.1rem; }
  .hero-networth-value { font-size: 0.92rem; }
  .hero-networth-note { flex-basis: 100%; font-size: 0.66rem; }
  .hero-holdings { gap: 0.2rem; margin-top: 0.4rem; }
  .hero-holdings-label { font-size: 0.58rem; letter-spacing: 0.12em; }
  .hero-holdings-value { font-size: 0.8rem; }
  /* Key figures: one row each, label left, figure right, so long amounts
     keep the narrow column's full width. */
  .hero-metrics { grid-template-columns: minmax(0, 1fr); row-gap: 0.32rem; margin-top: 0.7rem; padding-top: 0.6rem; }
  .hero-metric { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; padding: 0; border-left: none; }
  .hero-metric dt { flex: 0 0 auto; font-size: 0.58rem; letter-spacing: 0.12em; }
  .hero-metric dd { font-size: 0.78rem; text-align: right; }
  .hero-sub { font-size: 0.72rem; margin-top: 0.6rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hero-alloc { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; flex: 0 0 9.5rem; width: 9.5rem; margin-left: auto; align-self: flex-start; }
  /* DOM order is legend-then-ring; order pulls the ring on top. */
  .hero-alloc .donut-sm { order: -1; width: 7.25rem; height: 7.25rem; }
  /* Shrink-wrap + center: the block sits centered under the ring and only
     truncates (same … as desktop) when an entry outgrows the column. */
  .hero-alloc-legend { width: auto; max-width: 100%; gap: 0.3rem; }
  /* Size must sit on the li — it carries its own font-size that beats
     anything inherited from the ul. */
  .hero-alloc-legend li { gap: 0.35rem; font-size: 0.6rem; }
  .hero-alloc-dot { width: 0.45rem; height: 0.45rem; }
}

@media (max-width: 560px) {
  .hero-value { font-size: clamp(1.3rem, 7vw, 1.55rem); }
  .hero-alloc .donut-sm { width: 7rem; height: 7rem; }
}

@media (max-width: 380px) {
  #hero { gap: 0.35rem 0.6rem; padding: 1rem 0.7rem 0.9rem; }
  .hero-alloc { flex-basis: 9.25rem; width: 9.25rem; }
  .hero-alloc .donut-sm { width: 6.5rem; height: 6.5rem; }
  .hero-alloc-legend li { font-size: 0.6rem; }
}
