/* An investor's own page. It shares the portal's type and colours, and is set as one
   open sheet with the balance leading, in place of the boxed tiles and tabs staff use. */

/* Shown above the page when an Admin views an account as its investor. */
.preview-notice { align-items: center; }
.preview-notice > .icon { margin-top: 0; }

/* An investor with more than one account chooses between them above the sheet. */
.account-switcher { margin-bottom: var(--space-4); max-width: 100%; overflow-x: auto; }
.account-switcher > a { gap: var(--space-2); white-space: nowrap; }

/* The sheet: who the account belongs to, the balance, how it has moved, and four facts. */
.account-sheet {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5) var(--space-6);
    padding: 40px 44px 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}
.account-sheet.has-chart { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
/* Beside the chart, the name sits at the top and the balance lines up with the foot of the chart. */
.account-sheet.has-chart .account-summary { display: flex; flex-direction: column; }
.account-sheet.has-chart .account-balance { margin-top: auto; padding-top: var(--space-6); }
.account-sheet:not(:has(.account-facts)) { padding-bottom: 40px; }

.account-summary h1 { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.account-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--space-3); margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.account-balance {
    margin: var(--space-6) 0 0;
    font-size: 60px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.account-balance-cents { color: var(--muted); font-size: 0.5em; letter-spacing: -0.02em; }
.account-balance-date { margin: var(--space-2) 0 0; color: var(--muted); font-size: 14px; }
.account-waiting { margin: var(--space-5) 0 0; max-width: 46ch; font-size: 16px; }

.account-facts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: var(--space-3) 0 0; border-top: 1px solid var(--line); }
.account-facts > div { padding: var(--space-4) var(--space-5) var(--space-5); border-left: 1px solid var(--line); }
.account-facts > div:first-child { padding-left: 0; border-left: 0; }
.account-facts dt { color: var(--muted); font-size: 13px; }
.account-facts dd { margin: 2px 0 0; font-size: 19px; font-weight: 500; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.account-facts .account-fact-unit { color: var(--muted); font-size: 14px; font-weight: 400; letter-spacing: 0; }
.account-facts .account-fact-note { margin-top: 2px; color: var(--muted); font-size: 13px; font-weight: 400; letter-spacing: 0; }

/* A figure with more behind it shows that detail on hover, on keyboard focus and on a tap. */
.tip { position: relative; border-bottom: 1px dotted var(--control-line); cursor: help; }
.tip::after {
    content: attr(data-tip);
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 5;
    width: max-content;
    max-width: min(280px, 70vw);
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: 0;
    text-align: left;
    white-space: normal;
    opacity: 0;
    transform: translateY(3px);
    pointer-events: none;
    transition: opacity 0.14s ease-out, transform 0.14s ease-out;
}
.tip:hover::after,
.tip:focus::after { opacity: 1; transform: none; }
.tip:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
/* In the facts row the detail lines up with its column, so it never runs past the edge of the sheet,
   and opens below the figure so it does not cover the label it belongs to. */
.account-facts dd { position: relative; }
.account-facts .tip { position: static; }
.account-facts .tip::after { top: calc(100% + 8px); right: auto; bottom: auto; left: 0; }
.account-facts > div:last-child .tip::after { right: 0; left: auto; }

/* Balance chart */
.balance-chart { margin: 0; min-width: 0; }
.balance-chart-plot { position: relative; height: 176px; margin-right: 52px; }
.balance-chart-plot > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.balance-chart-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.balance-chart-line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.balance-chart-tick { position: absolute; left: calc(100% + 10px); transform: translateY(-50%); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.balance-chart-range { display: flex; justify-content: space-between; margin: var(--space-2) 52px 0 0; color: var(--muted); font-size: 12px; }

/* Each month is a column the pointer can rest anywhere in. Its marker and label show on hover, focus or tap. */
.balance-chart-points { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; }
.balance-chart-points > li { position: absolute; top: 0; bottom: 0; width: var(--column); transform: translateX(-50%); outline: none; }
.balance-chart-points > li::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--control-line); opacity: 0; }
.balance-chart-dot { position: absolute; top: var(--top); left: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border: 2px solid var(--surface); border-radius: 50%; background: var(--ink); opacity: 0; }
.balance-chart-label { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); padding: 5px 9px; border-radius: var(--radius-sm); background: var(--ink); color: #fff; font-size: 12px; line-height: 1.3; white-space: nowrap; opacity: 0; pointer-events: none; }
.balance-chart-label strong { margin-left: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.balance-chart-points > li.is-start .balance-chart-label { left: 50%; transform: none; }
.balance-chart-points > li.is-end .balance-chart-label { left: auto; right: 50%; transform: none; }
.balance-chart-points > li:hover::before,
.balance-chart-points > li:focus::before,
.balance-chart-points > li:hover > span,
.balance-chart-points > li:focus > span { opacity: 1; }
/* The latest month is always marked, in the brand gold. */
.balance-chart-points > li.is-latest .balance-chart-dot { width: 12px; height: 12px; margin: -6px 0 0 -6px; background: var(--gold); opacity: 1; }

/* Below the sheet: statements to download beside the record of the account. */
.account-columns { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-5); align-items: start; margin-top: var(--space-5); }
.account-statements { grid-column: 2; grid-row: 1; position: sticky; top: var(--space-5); padding: var(--space-5) var(--space-5) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.account-record { grid-column: 1; grid-row: 1; padding: var(--space-5) 0 var(--space-2); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.account-statements h2,
.account-record h2 { margin: 0; font-size: 16px; font-weight: 600; }
.account-empty { margin: var(--space-3) 0 var(--space-3); color: var(--muted); }
.account-record > .account-empty { padding: 0 var(--space-5); }

.statement-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.account-statements h2 + .statement-row { margin-top: var(--space-4); }
.statement-row p { margin: 0; }
.statement-quarter { font-weight: 600; }
.statement-period { color: var(--muted); font-size: 13px; }
.statement-earlier > summary { display: flex; align-items: center; justify-content: space-between; min-height: var(--touch); border-top: 1px solid var(--line); color: var(--ink-2); font-weight: 500; cursor: pointer; list-style: none; }
.statement-earlier > summary::-webkit-details-marker { display: none; }
.statement-earlier > summary .icon { color: var(--muted); transition: transform 0.16s ease-out; }
.statement-earlier[open] > summary .icon { transform: rotate(180deg); }
.statement-earlier > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* The record: a month, the balance it closed on, and what happened in it. */
.record-caption,
.record-month,
.record-year > summary { display: grid; grid-template-columns: minmax(0, 1fr) 150px 170px; column-gap: var(--space-4); padding-inline: var(--space-5); }
.record-caption { align-items: baseline; padding-bottom: var(--space-4); }
.record-caption > span { color: var(--muted); font-size: 13px; text-align: right; }

.record-year > summary { align-items: center; grid-template-columns: auto minmax(0, 1fr) auto; min-height: var(--touch); border-top: 1px solid var(--line); background: var(--surface-soft); cursor: pointer; list-style: none; }
.record-year > summary::-webkit-details-marker { display: none; }
.record-year-name { font-weight: 600; font-variant-numeric: tabular-nums; }
.record-year-total { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.record-year > summary .icon { color: var(--muted); transition: transform 0.16s ease-out; }
.record-year[open] > summary .icon { transform: rotate(180deg); }
.record-year[open] > summary .record-year-total { visibility: hidden; }
.record-year > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

.record-month { row-gap: 4px; padding-block: var(--space-4); border-top: 1px solid var(--line); }
.record-month p { margin: 0; }
.record-month-name { grid-column: 1 / 3; font-weight: 600; }
.record-month-balance { grid-column: 3; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.record-entry { grid-column: 1; color: var(--ink-2); }
.record-entry-date { display: inline-block; min-width: 58px; color: var(--muted); font-variant-numeric: tabular-nums; }
.record-entry-amount { grid-column: 2; font-variant-numeric: tabular-nums; text-align: right; }
/* In the record the detail behind a return shows on hover without marking every line. */
.record-entry-amount .tip { border-bottom: 0; }
/* Returns are paid to the investor rather than kept in the account, so they read quieter than money in and out. */
.record-entry-amount.is-return { color: var(--muted); }

/* Quiet legal footer below the investor sheet and activity record. */
.investor-legal {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}
.investor-legal p { margin: 0; max-width: 90ch; }
.investor-legal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: var(--space-2);
}
.investor-legal-links a {
    color: var(--muted);
    text-decoration: none;
    padding-block: 4px;
}
.investor-legal-links a:hover {
    color: var(--ink);
    text-decoration: underline;
}

@media (max-width: 1100px) {
    .account-sheet.has-chart { grid-template-columns: minmax(0, 1fr); }
    .account-columns { grid-template-columns: minmax(0, 1fr); }
    .account-statements,
    .account-record { grid-column: 1; grid-row: auto; position: static; }
}

@media (max-width: 640px) {
    .account-sheet { padding: var(--space-5) var(--space-4) 0; gap: var(--space-4); }
    .account-sheet:not(:has(.account-facts)) { padding-bottom: var(--space-5); }
    .account-balance { margin-top: var(--space-5); font-size: 42px; }
    .account-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .account-facts > div { padding: var(--space-3) var(--space-3) var(--space-3) 0; border-left: 0; border-top: 1px solid var(--line); }
    .account-facts > div:nth-child(-n+2) { border-top: 0; }
    .account-facts dd { font-size: 17px; }
    .account-facts dt { min-height: 2.6em; }
    .account-facts > div:nth-child(even) .tip::after { right: 0; left: auto; }
    .balance-chart-plot { height: 140px; margin-right: 44px; }
    .balance-chart-range { margin-right: 44px; }
    .account-statements { padding-inline: var(--space-4); }
    .record-caption,
    .record-month,
    .record-year > summary { padding-inline: var(--space-4); }
    .record-caption,
    .record-month { grid-template-columns: minmax(0, 1fr) auto; }
    .record-caption > span:first-of-type { display: none; }
    .record-month-name { grid-column: 1; }
    .record-month-balance { grid-column: 2; }
    .record-entry-amount { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
    .tip::after,
    .statement-earlier > summary .icon,
    .record-year > summary .icon { transition: none; }
}
