/*
 * The journal.
 *
 * One row per round trip, dense enough that a session's worth is scannable without
 * scrolling for it. Every numeric column is tabular so the digits line up — a column of
 * P&L that shifts by a pixel per row is a column nobody reads down.
 *
 * The colour carries the *net*, not the gross. A trade that made money before fees and lost
 * it after is a losing trade, and painting it green would be flattering the one number that
 * matters least.
 */

.journal {
  display: grid;
  gap: 1px;
  overflow-y: auto;
  min-block-size: 0;
}

.journal__row {
  display: grid;
  grid-template-columns: minmax(4.5rem, 1fr) 2.5rem 3rem minmax(7rem, 1.4fr) 3.5rem minmax(5rem, 1fr) minmax(5rem, 1fr) 4.5rem 1.2rem;
  gap: var(--sp-1);
  align-items: baseline;
  padding: 2px var(--sp-1);
  border-inline-start: 2px solid transparent;
  font-size: var(--fs-0);
}

.journal__row:nth-child(odd) {
  background: var(--bg-inset);
}

.journal__row--up {
  border-inline-start-color: var(--green);
}

.journal__row--down {
  border-inline-start-color: var(--orange);
}

.journal__inst {
  color: var(--ink-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal__side {
  color: var(--ink-muted);
  text-transform: uppercase;
}

.journal__hold,
.journal__cost,
.journal__excursion {
  color: var(--ink-muted);
}

.journal__net {
  text-align: end;
  font-weight: 700;
}

.journal__row--up .journal__net {
  color: var(--green);
}

.journal__row--down .journal__net {
  color: var(--orange);
}

/* The annotation controls. The pencil is dim until there is something to read, so a
   journal of unannotated rows does not look like a wall of unread messages. */
.journal__annotate {
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
}

.journal__annotate.is-on {
  color: var(--orange);
}

.journal__tags {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.journal__tag {
  font-size: var(--fs-0);
  letter-spacing: 0.04em;
}

.journal__editor {
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-1);
  border-block-start: 1px solid var(--line);
}

.journal__note {
  resize: vertical;
  font-size: var(--fs-0);
}

/*
 * The day lines. Heavier than a trade row and on their own surface, because they answer a
 * different question — was today good — and a scorecard that reads like another trade is a
 * scorecard the eye slides past.
 */
.journal__days {
  display: grid;
  gap: 1px;
  padding-block-end: var(--sp-1);
}

.journal__day {
  display: grid;
  grid-template-columns: minmax(6rem, 1.6fr) 3rem 3.5rem minmax(4rem, 1fr) 5rem;
  gap: var(--sp-2);
  align-items: baseline;
  inline-size: 100%;
  padding: 3px var(--sp-2);
  border: 0;
  border-inline-start: 2px solid transparent;
  background: var(--bg-raised);
  color: var(--ink);
  font-size: var(--fs-0);
  font-weight: 700;
  text-align: start;
  cursor: pointer;
}

/* Today stays in view while the scalping is happening: the running score is the number a
   trader checks between trades, and scrolling for it is scrolling away from the ticket. */
.journal__day--today {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  border-inline-start-color: var(--orange);
}

.journal__day--up .journal__daynet {
  color: var(--green);
}

.journal__day--down .journal__daynet {
  color: var(--orange);
}

.journal__daydate {
  color: var(--ink-strong);
}

.journal__daynet {
  text-align: end;
}

.journal__storage {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  padding-block-start: var(--sp-1);
}

.journal__bar {
  flex: 1;
  block-size: 3px;
  background: var(--bg-inset);
}

.journal__bar i {
  display: block;
  block-size: 100%;
  background: var(--green);
}

.journal__filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  align-items: center;
  padding-block-end: var(--sp-1);
}

/* The tag vocabulary as a filter bar. Scrollable rather than wrapping past two lines: the
   list of rows is what the block is for, and a tag bar that grows pushes it off screen. */
.journal__tagbar {
  display: flex;
  gap: var(--sp-1);
  overflow-x: auto;
  padding-block-end: var(--sp-1);
}

.journal__tagfilter {
  flex: none;
  font-size: var(--fs-0);
}

.journal__export {
  justify-self: start;
  font-size: var(--fs-0);
}

.journal__import {
  cursor: pointer;
}

.journal__error {
  margin: 0;
  color: var(--orange);
  font-size: var(--fs-0);
}

/*
 * The transport. Fixed at the foot of the screen because it is the one control that must be
 * reachable from anywhere in a session you are standing inside, and loud because a desk in
 * replay looks identical to a live one until you notice this bar.
 */
.transport {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  z-index: 45;
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  border-block-start: 1px solid var(--orange);
  background: var(--bg-raised);
}

.transport__badge {
  color: var(--orange);
  font-size: var(--fs-1);
  letter-spacing: 0.16em;
}

.transport__scrub {
  flex: 1;
  min-inline-size: 6rem;
  accent-color: var(--orange);
}

.journal__pins {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  padding: var(--sp-1) 0;
}

.journal__pin {
  font-size: var(--fs-0);
}

/*
 * Standing in the past. Fixed, centred and loud, because a trader who forgot they were
 * viewing history would read every number on the desk as the present one — and act on it.
 */
.replaying {
  position: fixed;
  inset-block-start: var(--sp-2);
  inset-inline: 0;
  z-index: 40;
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  justify-content: center;
  margin-inline: auto;
  inline-size: fit-content;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--orange);
  border-radius: var(--radius-1);
  background: var(--bg-raised);
  color: var(--orange);
  font-size: var(--fs-1);
  letter-spacing: 0.12em;
  box-shadow: var(--glow-orange);
}

/* Narrow screens drop the columns a trader can reconstruct — the entry/exit prices and the
   excursion — before the ones they cannot: what it was, and what it paid. A media query
   rather than a container query, matching the breakpoint the grid already uses; nothing in
   this codebase declares a container-type, and a @container rule with no container silently
   never matches. */
@media (max-width: 40rem) {
  .journal__row {
    grid-template-columns: minmax(4rem, 1fr) 2.5rem 3.5rem 4.5rem 1.2rem;
  }

  .journal__qty,
  .journal__px,
  .journal__excursion,
  .journal__cost {
    display: none;
  }
}

/*
 * The record toggle.
 *
 * An unmissable dot, because a desk that is quietly recording and a desk that is not look
 * identical otherwise - and finding out you were not recording is always retrospective.
 */
.rec {
  display: flex;
  flex: 0 0 auto;
  margin-block-end: var(--sp-1);
}

.chip--rec {
  border-color: var(--orange);
  color: var(--orange);
}

.rec__dot {
  display: inline-block;
  inline-size: 0.5rem;
  block-size: 0.5rem;
  margin-inline-end: var(--sp-1);
  border-radius: 50%;
  background: var(--orange);
  animation: rec-pulse 1.4s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* A pulse that never stops is a distraction on a desk read for hours. */
@media (prefers-reduced-motion: reduce) {
  .rec__dot { animation: none; }
}

/*
 * The recording library.
 *
 * One row per session, mono and dense like everything else that gets scanned rather than
 * read. The delete is a bare glyph with no confirm behind it: speed is the product, and a
 * recording is the one thing on this desk whose loss costs nothing but disk.
 */
.library {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-block-size: 0;
  font-variant-numeric: tabular-nums;
}

.library__row {
  display: grid;
  grid-template-columns: 1.6fr 1.2fr 0.7fr 0.6fr 0.7fr auto auto;
  gap: var(--sp-1);
  align-items: baseline;
  padding-block: var(--sp-1);
}

.library__label {
  min-inline-size: 0;
  border: 0;
  border-block-end: 1px solid transparent;
  background: none;
  color: var(--ink-strong);
  font: inherit;
}

/* Editable, but only obviously so once reached for - a row of boxes reads as a form. */
.library__label:hover,
.library__label:focus {
  border-block-end-color: var(--line);
  outline: none;
}

.library__meta {
  text-align: right;
  color: var(--ink-muted);
}

.library__x {
  border: 0;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  font: inherit;
}

.library__x:hover {
  color: var(--orange);
}

/*
 * The replay transport.
 *
 * One row: what is loaded, where in it, how fast, and the way back to live. Paused is
 * orange because a desk showing prices that are not current is a desk that must never be
 * mistaken for a live one.
 */
.transport {
  display: flex;
  gap: var(--sp-1);
  align-items: center;
  flex: 0 0 auto;
  padding-block: var(--sp-1);
  border-block-end: 1px solid var(--line);
  margin-block-end: var(--sp-1);
}

.transport__label {
  min-inline-size: 0;
  color: var(--orange);
}

.transport__clock {
  margin-inline-start: auto;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.transport__speeds {
  display: flex;
  gap: 2px;
}

.library__play {
  border: 0;
  background: none;
  color: var(--green);
  cursor: pointer;
  font: inherit;
}
