/* The price trace: a lever, a ladder of steps from profit to US tax, and the group's tiles. */
.trace-page { display: grid; gap: 16px; }
.trace-lever { display: grid; gap: 12px; padding: 17px 20px; }
.trace-field { display: grid; gap: 5px; max-width: 520px; color: var(--secondary); font-size: 12px; font-weight: 670; }
.trace-field select { min-height: 38px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-size: 14px; }
.trace-slider-row { display: flex; align-items: center; gap: 10px; max-width: 640px; }
.trace-slider { position: relative; flex: 1 1 auto; padding: 8px 0; }
.trace-slider input { display: block; width: 100%; margin: 0; accent-color: var(--navy); }
/* Where the budget's setting sits on the slider. */
.trace-budget-mark {
  position: absolute;
  bottom: -2px;
  left: calc(8px + (100% - 16px) * var(--budget-fraction, .5));
  width: 2px;
  height: 7px;
  margin-left: -1px;
  background: var(--secondary);
  pointer-events: none;
}
.trace-nudge { min-width: 38px; justify-content: center; font-size: 18px; line-height: 1; }
.trace-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 13px; color: var(--secondary); }
.trace-value strong { color: var(--navy); font-size: 24px; letter-spacing: -.03em; }
.trace-delta { padding: 2px 8px; border-radius: 99px; background: #eef3f9; color: var(--navy); font-size: 12px; font-weight: 680; }
.trace-caption { color: var(--secondary); font-size: 12px; line-height: 1.45; }
.trace-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.trace-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--secondary); font-size: 11px; font-weight: 650; }
.trace-key { display: inline-flex; align-items: center; gap: 5px; }
.trace-key::before { content: ""; display: block; width: 16px; height: 9px; border-radius: 2px; }
.trace-key.up::before { background: var(--blue); }
.trace-key.down::before { background: repeating-linear-gradient(135deg, var(--royalty) 0 3px, #e3c6a6 3px 6px); }
.trace-key.outline::before { border: 1.5px solid var(--blue); }
.trace-key.lost::before { border: 1px dashed #7d8796; background: repeating-linear-gradient(45deg, #9aa5b4 0 2px, transparent 2px 5px); }

/* The ladder scrolls sideways inside its own panel; the page never does. */
.trace-scroll { overflow-x: auto; padding: 0 0 6px; }
.trace-ladder { --label: 150px; --column: 172px; min-width: calc(var(--label) + var(--columns) * var(--column)); }
.trace-row { display: grid; grid-template-columns: var(--label) repeat(var(--columns), minmax(var(--column), 1fr)); border-top: 1px solid var(--line); transition: opacity .3s, background-color .3s; }
.trace-head { border-top: 0; }
.trace-cell { position: relative; min-width: 0; padding: 12px 14px; }
.trace-row-label { position: sticky; left: 0; z-index: 1; display: flex; align-items: flex-start; gap: 7px; background: var(--surface); color: var(--navy); font-size: 13px; font-weight: 700; box-shadow: 1px 0 0 var(--line); }
.trace-step { color: var(--blue); font-size: 15px; line-height: 1.1; }
.trace-entity { display: grid; gap: 2px; padding-bottom: 8px; }
.trace-entity strong { color: var(--navy); font-size: 13px; }
.trace-entity span { color: var(--secondary); font-size: 11px; font-weight: 600; }
.trace-parent { background: #f6f9fd; }
.trace-row > .trace-cell:last-child { background: #f6f9fd; }
.trace-row > .trace-row-label:last-child { background: var(--surface); }
.trace-muted { color: var(--secondary); font-size: 11px; line-height: 1.4; }
.trace-help-label { cursor: help; border-bottom: 1px dotted #9fb2c9; }

/* A bar from the centre line: right for a rise, solid; left for a fall, hatched. */
.trace-bar-line { display: grid; gap: 2px; padding: 2px 0; border-radius: 6px; cursor: help; outline-offset: 2px; }
.trace-bar-line:hover { background: #f3f8ff; }
.trace-bar-label { color: var(--secondary); font-size: 10.5px; font-weight: 650; }
.trace-track { position: relative; height: 14px; background: linear-gradient(#b9c6d6, #b9c6d6) center / 1px 100% no-repeat; }
.trace-bar { position: absolute; top: 2px; bottom: 2px; width: calc(var(--size) * 50%); }
.trace-bar-line.up .trace-bar { left: 50%; border-radius: 0 3px 3px 0; background: var(--blue); }
.trace-bar-line.down .trace-bar { right: 50%; border-radius: 3px 0 0 3px; background: repeating-linear-gradient(135deg, var(--royalty) 0 3px, #e3c6a6 3px 6px); }
.trace-bar-line.outline .trace-bar { background: transparent; border: 1.5px solid var(--blue); }
.trace-bar-line.outline.down .trace-bar { border: 1.5px dashed var(--royalty); }
.trace-bar-line.lost .trace-bar { border: 1px dashed #7d8796; background: repeating-linear-gradient(45deg, #9aa5b4 0 2px, transparent 2px 5px); }
.trace-bar-line.flat .trace-bar { display: none; }
.trace-amount { font-size: 12px; font-weight: 720; text-align: center; color: var(--secondary); }
.trace-bar-line.up .trace-amount { padding-left: 50%; text-align: left; color: #34587f; }
.trace-bar-line.down .trace-amount { padding-right: 50%; text-align: right; color: #7a4e22; }
.trace-split { display: grid; gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.trace-cell > .trace-split:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.trace-parts .trace-amount { font-size: 11px; }

/* The markers: the seesaw between the two parties, and the flow towards the US parent. */
.trace-marker { position: absolute; top: 14px; right: -11px; z-index: 2; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 50%; background: #fff; color: var(--navy); font-size: 13px; font-weight: 700; }
.trace-empty { display: flex; align-items: center; }

/* The trace: the steps light one by one. */
.trace-ladder.tracing .trace-row:not(.trace-head):not(.lit) { opacity: .16; }
.trace-row.current { background: #f3f8ff; box-shadow: inset 3px 0 0 var(--navy); }
.trace-row.current > .trace-row-label { background: #f3f8ff; }
.trace-results { display: grid; gap: 16px; }
.trace-results.working .trace-ladder, .trace-results.working .trace-tiles { opacity: .55; transition: opacity .15s; }
.trace-up { color: #34587f; }
.trace-down { color: #7a4e22; }
.tax-help-lead { font-weight: 560; }

@media (max-width: 755px) {
  .trace-lever { padding: 13px; }
  .trace-ladder { --label: 80px; --column: 128px; }
  .trace-cell { padding: 10px 8px; }
  .trace-row-label { font-size: 11px; gap: 3px; }
  .trace-step { font-size: 13px; }
  .trace-entity strong { font-size: 12px; }
  /* Each amount sits on the side its bar runs to. */
  .trace-bar-line.up .trace-amount { padding-left: 0; text-align: right; }
  .trace-bar-line.down .trace-amount { padding-right: 0; text-align: left; }
  .trace-value strong { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .trace-row, .trace-results.working .trace-ladder { transition: none; }
}
