/* The public /trading-performance page.
 *
 * Loads after trades-page.css and portfolio-page.css and adds only what this
 * page needs. The three product pages share one vocabulary on purpose — the
 * section furniture, the widget frame, the table and the jump nav are all the
 * same elements. What is different here is the SKIN: this page is drawn as a
 * data sheet, because its whole claim is that every figure can be checked.
 * A field name, a dotted leader, the number, and underneath it the sentence
 * that says what the field means. A card with a big number and a gradient
 * behind it would be making the opposite promise.
 *
 * Green and red appear only on a figure that is genuinely a gain or a loss.
 * A profit factor, a payoff ratio and a win rate are not results — they are
 * ratios, and colouring them would tell the reader something the number does
 * not say.
 *
 * Nothing here is drawn by JavaScript. The curves are paths the server has
 * already computed, so they are in the document with scripts blocked and in
 * a search index.
 */

/* ---- the sheet ----------------------------------------------------------- */

.pe-term {
  --pe-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --pe-hair: color-mix(in srgb, var(--border) 60%, transparent);
}

/* Faint graph paper, the way a reading is printed on a sheet rather than on
   a page. It sits under the hero only, so the rest of the page stays quiet. */
.pe-hero {
  background-image:
    repeating-linear-gradient(90deg, var(--pe-hair) 0 1px, transparent 1px 52px),
    repeating-linear-gradient(0deg, var(--pe-hair) 0 1px, transparent 1px 52px);
  background-position: center top;
}

/* Every number on this page is monospaced, so a column of them lines up and
   two readings can be compared by eye without reading either of them. */
.pe-term .tp-num,
.pe-term .pe-k,
.pe-term .pe-calc {
  font-family: var(--pe-mono);
}

/* ---- the command that produced the sheet --------------------------------- */

/* Aria-hidden in the markup: it is a picture of a command, and a screen
   reader gets the heading underneath it instead. */
.pe-prompt {
  margin: 0 0 6px;
  font-family: var(--pe-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* The command reads left to right in every language — reversing a flag would
   make it a different command — but the line still begins where the reader
   begins, so the paragraph keeps the page's own direction. */
.pe-line {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  direction: ltr;
  unicode-bidi: isolate;
}

/* The tokens sit tight against each other, and the gaps that belong in a
   command line are put back one at a time — a space written as text would be
   one more thing the English sweep has to read. */
.pe-user { color: var(--cyan); }
.pe-at { color: var(--text-muted); }
.pe-path { color: var(--blue); margin-inline-start: 4px; }
.pe-sign { color: var(--text-muted); }
.pe-cmd { color: var(--text); margin-inline-start: 8px; }
.pe-flag { color: var(--amber); margin-inline-start: 8px; }
.pe-eq { color: var(--text-muted); }
.pe-arg { color: var(--text-secondary); }

.pe-caret {
  margin-inline-start: 8px;
  inline-size: 7px;
  block-size: 14px;
  background: var(--cyan);
  animation: pe-blink 1.15s steps(1, end) infinite;
}

@keyframes pe-blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .pe-caret { animation: none; }
}

/* ---- a panel of the sheet ------------------------------------------------ */

/* Squarer than the other pages' cards, and with a printed header rather than
   a titled one. It is the same element underneath, so the "Example" mark and
   the shared spacing come for free. */
.pe-term .pe-blk {
  border-radius: var(--radius-sm);
  box-shadow: none;
  border-color: var(--border-strong);
}

.pe-term .pe-blk-h {
  padding-block: 8px;
}

.pe-term .pe-blk-h .tp-widget-title {
  font-family: var(--pe-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.pe-blk-meta {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pe-blk + .pe-blk { margin-top: 18px; }

/* ---- one reading --------------------------------------------------------- */

.pe-spec {
  display: grid;
}

.pe-row {
  display: grid;
  grid-template-columns: max-content minmax(20px, 1fr) max-content;
  grid-template-areas:
    "key dots value"
    "note note value";
  align-items: baseline;
  column-gap: 10px;
  padding: 11px 16px;
}

.pe-row + .pe-row { border-top: .5px solid var(--pe-hair); }

.pe-k {
  grid-area: key;
  font-size: 12.5px;
  color: var(--cyan);
  white-space: nowrap;
}

/* The tree glyph in front of a child reading. Decoration, and separate from
   the field name so that the name stays one token. */
.pe-branch {
  color: var(--text-muted);
  margin-inline-end: 6px;
}

/* The leader. Decoration, so it carries no meaning a reader could miss. */
.pe-dots {
  grid-area: dots;
  border-block-end: 1px dotted var(--border-strong);
  translate: 0 -4px;
  min-inline-size: 20px;
}

/* The arithmetic, printed where a sheet would print it. It reads left to
   right in every language, because a division written right to left is a
   different division. */
.pe-calc {
  grid-area: dots;
  justify-self: end;
  padding-inline: 8px;
  background: var(--surface);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.tp-section.is-alt .pe-calc { background: var(--surface-raised); }

.pe-v {
  grid-area: value;
  align-self: center;
  text-align: end;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.pe-note {
  grid-area: note;
  margin-block-start: 4px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

@media (max-width: 720px) {
  .pe-row {
    grid-template-columns: minmax(0, 1fr) max-content;
    grid-template-areas:
      "key value"
      "note note";
  }
  .pe-dots, .pe-calc { display: none; }
}

/* ---- the split between the two populations ------------------------------- */

.pe-meter {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-top: .5px solid var(--border);
}

.pe-meter-row {
  display: grid;
  grid-template-columns: minmax(90px, max-content) minmax(60px, 1fr) max-content max-content;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.pe-meter-track,
.pe-share-track {
  block-size: 8px;
  border-radius: 999px;
  background: var(--bg);
  border: .5px solid var(--border);
  overflow: hidden;
  /* A proportion is a picture of a quantity, and a quantity does not mirror. */
  direction: ltr;
}

.pe-meter-track i,
.pe-share-track i {
  display: block;
  block-size: 100%;
}

.pe-meter-track i.is-pos,
.pe-share-track i.is-pos { background: var(--green); }

.pe-meter-track i.is-neg,
.pe-share-track i.is-neg { background: var(--red); }

.pe-meter-track i.is-accent { background: var(--cyan); }

.pe-meter-row b { font-weight: 700; }

@media (max-width: 640px) {
  .pe-meter-row {
    grid-template-columns: minmax(0, 1fr) max-content;
    row-gap: 6px;
  }
  .pe-meter-track { grid-column: 1 / -1; order: 3; }
}

/* ---- the four-cell reading under a chart --------------------------------- */

.pe-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: .5px solid var(--border);
}

.pe-strip > div {
  padding: 12px 16px;
  border-inline-start: .5px solid var(--border);
  min-width: 0;
}

.pe-strip > div:first-child { border-inline-start: 0; }

/* The label only: a figure inside the <b> is a span too, and matching it here
   is how a 17px reading quietly rendered at 9.5px. */
.pe-strip > div > span {
  display: block;
  /* 10.5px is the floor for a label a reader is meant to read. Below that it
     reads as decoration, and these four name the four figures the section is
     about. */
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pe-strip b {
  display: block;
  margin-block-start: 5px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .pe-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pe-strip > div:nth-child(3) { border-inline-start: 0; }
  .pe-strip > div:nth-child(n+3) { border-top: .5px solid var(--border); }
}

/* ---- the curves ---------------------------------------------------------- */

/* A time axis never mirrors. January is on the reading side of December in
   Arabic too, because the chart is a picture of time passing and reversing
   it would say the account lost what it made. */
.pe-chart {
  direction: ltr;
  padding: 12px 16px 0;
}

.pe-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.pe-grid line {
  stroke: var(--border);
  stroke-width: 1;
}

.pe-curve {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.pe-area {
  fill: var(--cyan-dim, color-mix(in srgb, var(--cyan) 12%, transparent));
  stroke: none;
}

.pe-dot { fill: var(--cyan); }

.pe-mark {
  fill: var(--text);
  font-family: var(--pe-mono);
  font-size: 11px;
  font-weight: 700;
}

.pe-tick {
  fill: var(--text-muted);
  font-family: var(--pe-mono);
  font-size: 10px;
  letter-spacing: .06em;
}

/* The stretch between the peak and the day it got back. */
.pe-band { fill: color-mix(in srgb, var(--red) 9%, transparent); }

.pe-rule {
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.pe-pin text {
  font-family: var(--pe-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
}

.pe-pin.is-peak rect { fill: var(--text-secondary); }
.pe-pin.is-peak text { fill: var(--text-secondary); }
.pe-pin.is-trough rect { fill: var(--red); }
.pe-pin.is-trough text { fill: var(--red); }
.pe-pin.is-back rect { fill: var(--green); }
.pe-pin.is-back text { fill: var(--green); }

/* ---- net P&L by month ---------------------------------------------------- */

/* Twelve months read in one direction whatever the page direction is. */
/* The rows are fixed heights rather than fractions, because the bar heights
   are computed against ONE scale in the page module: a 1fr row in an
   auto-height grid collapses to nothing, and the gain bars vanish. */
.pe-bars {
  --pe-up: 107px;
  --pe-down: 46px;
  display: flex;
  gap: 5px;
  padding: 18px 16px 8px;
  direction: ltr;
}

.pe-bar {
  flex: 1;
  display: grid;
  grid-template-rows: var(--pe-up) 1px var(--pe-down) 16px;
  align-items: end;
  justify-items: center;
  min-width: 0;
}

.pe-bar-up,
.pe-bar-down {
  display: flex;
  inline-size: 100%;
  align-self: stretch;
}

.pe-bar-up { align-items: flex-end; }
.pe-bar-down { align-items: flex-start; }

.pe-bar i {
  display: block;
  inline-size: 100%;
  border-radius: 2px;
}

.pe-bar i.is-pos { background: linear-gradient(180deg, var(--green), color-mix(in srgb, var(--green) 30%, transparent)); }
.pe-bar i.is-neg { background: linear-gradient(0deg, var(--red), color-mix(in srgb, var(--red) 30%, transparent)); }

.pe-bar-zero {
  display: block;
  inline-size: 100%;
  block-size: 1px;
  background: var(--border-strong);
}

.pe-bar-name {
  font-family: var(--pe-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  align-self: end;
}

.pe-bars-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 26px;
  padding: 0 16px 16px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.pe-bars-foot b { font-weight: 700; }

/* ---- tables -------------------------------------------------------------- */

.pe-table th,
.pe-table td { padding-block: 9px; }

.pe-table td { font-size: 12.5px; }

/* A row that is printed so the totals add up, but is not in the comparison. */
tr.pe-thin td { color: var(--text-muted); }

.pe-share { inline-size: 160px; }

/* A row that is shown but never ranked reads as one: dimmer, and with the
   reason spelled out beside the name rather than left to the styling. */
tr.pe-unranked td { color: var(--text-muted); }

.pe-note-tag {
  display: inline-block;
  margin-inline-start: 6px;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  border: .5px solid var(--border-strong);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- weekday against the hour of the close ------------------------------- */

/* The shade is the size of the result, and it is deliberately NOT applied to
   a cell with too few trades in it: those print their sample size instead.
   Four trades shaded like an edge is the flattery this page refuses. */
.pe-heat td.pe-cell {
  text-align: center;
  font-size: 11.5px;
}

.pe-cell.is-pos { background: color-mix(in srgb, var(--green) calc(var(--weight) * 40%), transparent); }
.pe-cell.is-neg { background: color-mix(in srgb, var(--red) calc(var(--weight) * 40%), transparent); }

.pe-cell.is-thin {
  background: color-mix(in srgb, var(--text-muted) 7%, transparent);
  color: var(--text-muted);
}

/* ---- the eight views, switching without a line of JavaScript ------------- */

/* Eight radios, eight labels, eight panels, all siblings; `:checked ~` picks
   the panel. Every panel's content is therefore in the HTML at load, which is
   the whole argument for doing it this way: a crawler, an assistant, a screen
   reader and a reader with scripts blocked all get eight views' worth of real
   tables on one page instead of one eighth of it.

   The radios are moved off-screen rather than set to `display: none`, because
   a hidden input cannot take focus and the arrow keys are how a radio group is
   operated from a keyboard. The same pattern runs the asset sheet next door on
   /portfolio-tracker. */
.pe-tabbed > input {
  position: absolute;
  opacity: 0;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}

.pe-panels > .pe-panel { display: none; }

#pe-tab-overview:checked ~ .pp-tabs [for="pe-tab-overview"],
#pe-tab-strategies:checked ~ .pp-tabs [for="pe-tab-strategies"],
#pe-tab-assets:checked ~ .pp-tabs [for="pe-tab-assets"],
#pe-tab-time:checked ~ .pp-tabs [for="pe-tab-time"],
#pe-tab-winloss:checked ~ .pp-tabs [for="pe-tab-winloss"],
#pe-tab-drawdown:checked ~ .pp-tabs [for="pe-tab-drawdown"],
#pe-tab-expectancy:checked ~ .pp-tabs [for="pe-tab-expectancy"],
#pe-tab-breakdowns:checked ~ .pp-tabs [for="pe-tab-breakdowns"] {
  color: var(--cyan);
  border-color: var(--cyan);
  background: var(--cyan-dim);
}

/* The focus ring belongs on the label, since the input it belongs to is the
   one off-screen. */
#pe-tab-overview:focus-visible ~ .pp-tabs [for="pe-tab-overview"],
#pe-tab-strategies:focus-visible ~ .pp-tabs [for="pe-tab-strategies"],
#pe-tab-assets:focus-visible ~ .pp-tabs [for="pe-tab-assets"],
#pe-tab-time:focus-visible ~ .pp-tabs [for="pe-tab-time"],
#pe-tab-winloss:focus-visible ~ .pp-tabs [for="pe-tab-winloss"],
#pe-tab-drawdown:focus-visible ~ .pp-tabs [for="pe-tab-drawdown"],
#pe-tab-expectancy:focus-visible ~ .pp-tabs [for="pe-tab-expectancy"],
#pe-tab-breakdowns:focus-visible ~ .pp-tabs [for="pe-tab-breakdowns"] {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

#pe-tab-overview:checked ~ .pe-panels > #pe-panel-overview,
#pe-tab-strategies:checked ~ .pe-panels > #pe-panel-strategies,
#pe-tab-assets:checked ~ .pe-panels > #pe-panel-assets,
#pe-tab-time:checked ~ .pe-panels > #pe-panel-time,
#pe-tab-winloss:checked ~ .pe-panels > #pe-panel-winloss,
#pe-tab-drawdown:checked ~ .pe-panels > #pe-panel-drawdown,
#pe-tab-expectancy:checked ~ .pe-panels > #pe-panel-expectancy,
#pe-tab-breakdowns:checked ~ .pe-panels > #pe-panel-breakdowns {
  display: block;
}

/* Every panel is at least the height of a middling one, so switching views
   does not jump the page around under the reader's cursor. */
.pe-panels { min-block-size: 430px; }

.pe-panels .pe-comment { border-top: 0; }

/* A title inside a panel, with the population it is computed on beside it. */
.pe-subhead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0;
  padding: 14px 16px 0;
  font-family: var(--pe-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.pe-subhead span {
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: none;
  color: var(--text-muted);
}

/* Two or four small tables side by side inside a panel. */
.pe-duo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
}

.pe-duo > div { border-top: .5px solid var(--pe-hair); min-width: 0; }
.pe-duo > div:nth-child(odd) { border-inline-end: .5px solid var(--pe-hair); }

@media (max-width: 760px) {
  .pe-duo { grid-template-columns: minmax(0, 1fr); }
  .pe-duo > div:nth-child(odd) { border-inline-end: 0; }
}

/* A ranking, drawn as bars rather than as one more table. */
.pe-ranks {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
}

.pe-rank {
  display: grid;
  grid-template-columns: minmax(90px, max-content) minmax(60px, 1fr) max-content;
  align-items: center;
  gap: 4px 12px;
  font-size: 12.5px;
}

.pe-rank small {
  grid-column: 1 / -1;
  font-size: 10.5px;
  color: var(--text-muted);
}

.pe-rank.is-thin > span:first-child,
.pe-rank.is-thin small { color: var(--text-muted); }

.pe-rank b { font-weight: 700; }

/* The total row that proves a grouping adds up to the same figure. */
tr.pe-total td {
  border-top: .5px solid var(--border-strong);
  font-weight: 700;
}

.pe-formula-wide { margin: 14px 16px; }

/* The one paragraph under the drawdown panel, which no longer shares its row
   with a second column. */
.pe-aside { margin-block-start: 22px; max-inline-size: 78ch; }

@media (max-width: 640px) {
  .pe-rank { grid-template-columns: minmax(0, 1fr) max-content; }
  .pe-rank .pe-share-track { grid-column: 1 / -1; order: 3; }
  .pe-formula-wide { margin-inline: 16px; }
}

/* ---- what the page will not do ------------------------------------------- */

.pe-checks {
  list-style: none;
  margin: 0;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 26px;
}

.pe-checks li {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 11px;
  align-items: start;
}

.pe-checks b {
  font-size: 13px;
  font-weight: 650;
}

.pe-checks span:last-child {
  grid-column: 2;
  margin-block-start: 3px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.pe-tick {
  grid-row: span 2;
  display: grid;
  place-items: center;
  inline-size: 26px;
  block-size: 26px;
  border-radius: 8px;
  color: var(--cyan);
  background: var(--cyan-dim);
  border: .5px solid color-mix(in srgb, var(--cyan) 35%, transparent);
}

@media (max-width: 760px) {
  .pe-checks { grid-template-columns: minmax(0, 1fr); }
}

/* ---- a comment line ------------------------------------------------------ */

/* The sheet's own footnote. The hash is decoration, so it is drawn rather
   than written into the sentence a screen reader reads out. */
.pe-comment {
  margin: 0;
  padding: 12px 16px;
  border-top: .5px solid var(--border);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-muted);
}

.pe-comment::before {
  content: "#";
  font-family: var(--pe-mono);
  margin-inline-end: 7px;
  color: var(--text-muted);
  opacity: .7;
}

/* ---- questions ----------------------------------------------------------- */

.pe-qa { margin-block-start: 4px; }

/* ---- formulas ------------------------------------------------------------ */

.pe-formulas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-block-start: 20px;
}

.pe-formulas article {
  background: var(--bg);
  border: .5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.pe-formulas h3 {
  font-size: 14.5px;
  font-weight: 640;
  margin: 0 0 10px;
}

/* The formula is the claim. It reads left to right in every language,
   because a division written right to left is a different division. */
.pe-formula {
  margin: 0 0 10px;
  padding: 9px 12px;
  font-family: var(--pe-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: var(--surface-raised);
  border: .5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  overflow-wrap: anywhere;
}

.pe-formulas p:last-child {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ---- two panels side by side --------------------------------------------- */

.pe-two { margin-block-start: 18px; }
.pe-two + .pe-blk { margin-block-start: 18px; }
