/*
 * Motor Trade - clarity pass for the screens app.js draws itself, at laptop
 * sizes (1366x768 and 1440x900).
 *
 * lib/ui-motor-market.js is not mounted by app.js; the live forecourt cards,
 * their group headings, the sub-tabs and the navy sidebar are app.js markup
 * styled by styles.css. This file is loaded after styles.css and the other
 * motor stylesheets and only restyles that live markup - it adds no element,
 * moves no control and changes nothing a button does. Everything is scoped
 * under .motor-theme so the cafe game cannot change.
 *
 * What it settles, in order:
 *   1. the sidebar fits a 768px-tall screen: the menu scrolls inside its own
 *      rail when fifteen entries do not fit, and the student's name, the
 *      round and Logout never leave the screen;
 *   2. one calm card grammar on Your forecourt: whole 4:3 photograph on white
 *      (contain, never cover), a "whose move" pill from the card's own
 *      data-turn-label, label-left figure-right lines with tabular numerals,
 *      ONE solid primary action, a quiet Decline, the deal chat as a footer;
 *   3. group headings that read as headings, with the count as a chip;
 *   4. the sub-tabs, the guide box and the empty state in the same one-accent
 *      palette (teal), with the cafe gold gone from the motor forecourt.
 *
 * One accent (#00858f teal). No emoji, no gradients, no animation.
 */

.motor-theme {
  --mpc-accent: var(--mt-accent, #00858f);
  --mpc-accent-strong: var(--mt-accent-strong, #006e78);
  --mpc-accent-soft: var(--mt-accent-soft, #e2f1f2);
  --mpc-accent-line: var(--mt-accent-line, #9fd3d6);
  --mpc-ink: var(--mt-ink, #16202c);
  --mpc-ink-soft: var(--mt-ink-soft, #3c4753);
  --mpc-ink-muted: var(--mt-ink-muted, #5d6a78);
  --mpc-line: var(--mt-line, #e3e7ea);
  --mpc-line-soft: var(--mt-line-soft, #eef1f3);
  --mpc-surface: var(--mt-surface, #ffffff);
  --mpc-inset: var(--mt-inset, #f3f5f7);
  --mpc-amber-bg: var(--mt-amber-bg, #fff4dd);
  --mpc-amber-ink: var(--mt-amber-ink, #7a4f10);
  --mpc-amber-line: var(--mt-amber-line, #f0d39a);
  --mpc-grey-bg: var(--mt-grey-bg, #eef0f3);
  --mpc-grey-ink: var(--mt-grey-ink, #5a6673);
  --mpc-green-bg: var(--mt-green-bg, #dcf3e8);
  --mpc-green-ink: var(--mt-green-ink, #0f6b4a);
}

/* ---------- 1. the sidebar fits the screen ---------------------------------
   styles.css sets the motor sidebar to overflow-y: hidden so the menu is never
   "a second scrolling page". At 1366x768 the combined CEO & Finance rail needs
   933px and Finance 876px, so 108-165px of it was simply cut off - and the
   guide's scrollIntoView on the menu then scrolled the hidden overflow and
   left the student's own name off the top with no way back. The rail is a
   flex column already; the menu becomes the one part that yields and scrolls,
   so the brand row, the name, the job line, the round and Logout stay put. */
.motor-theme #screen-game > .sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.motor-theme #screen-game > .sidebar > .nav-list {
  flex: 1 1 auto;
  min-height: 96px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.45) rgba(255, 255, 255, 0.06);
  padding-bottom: 6px;
}
.motor-theme #screen-game > .sidebar > .nav-list::-webkit-scrollbar { width: 8px; }
.motor-theme #screen-game > .sidebar > .nav-list::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.06); }
.motor-theme #screen-game > .sidebar > .nav-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.45);
  border-radius: 999px;
}
.motor-theme #screen-game > .sidebar > .phase-indicator,
.motor-theme #screen-game > .sidebar > .sb-footer,
.motor-theme #screen-game > .sidebar > .sb-header,
.motor-theme #screen-game > .sidebar > .player-card,
.motor-theme #screen-game > .sidebar > .team-chip,
.motor-theme #screen-game > .sidebar > .locale-switcher--sidebar { flex: 0 0 auto; }
/* The menu is the part that scrolls, so the ring the guide draws on it must
   not ask the rail to scroll the name away. */
.motor-theme #screen-game > .sidebar > .nav-list.motor-guide-focus { outline-offset: -3px; }

/* On a 768px screen the block above the menu gives up its spare air, so an
   eight-entry menu fits whole and as much as possible of a fifteen-entry one
   is on screen before it has to scroll. Rows keep their 30px tap height. */
@media (max-height: 820px) {
  .motor-theme #screen-game > .sidebar > .sb-header { padding-top: 10px; padding-bottom: 6px; }
  .motor-theme #screen-game > .sidebar > .player-card { margin-top: 4px !important; margin-bottom: 4px !important; }
  .motor-theme #screen-game > .sidebar .pc-info { padding: 8px 10px 7px; }
  .motor-theme #screen-game > .sidebar .motor-role-note { margin-top: 3px; line-height: 1.4; }
  .motor-theme #screen-game > .sidebar .motor-next-step { margin-top: 7px; }
  .motor-theme #screen-game > .sidebar .motor-guide-open { margin-top: 5px; margin-bottom: 0; padding-top: 5px; padding-bottom: 5px; }
  .motor-theme #screen-game > .sidebar > .locale-switcher--sidebar { margin: 4px 10px 4px !important; }
  .motor-theme #screen-game > .sidebar > .locale-switcher--sidebar .locale-switcher__toggle { padding-top: 5px; padding-bottom: 5px; }
  .motor-theme #screen-game > .sidebar > .team-chip { margin-top: 3px; margin-bottom: 3px; }
  /* The "Your workspace" caption is the one line the menu can spare on a
     short screen: the menu is the only list in the rail. */
  .motor-theme #screen-game > .sidebar .nav-list > .nav-section-label { display: none; }
  .motor-theme #screen-game > .sidebar > .nav-list { padding-top: 4px; padding-bottom: 4px; }
  .motor-theme #screen-game > .sidebar > .phase-indicator { margin: 5px 10px; padding: 7px 12px; }
  .motor-theme #screen-game > .sidebar > .sb-footer { padding: 7px 8px; }
}

/* A page that opens in a LATER phase stays in the menu but reads as locked:
   the row is dimmed and blurred, it takes no click (app.js sets
   pointer-events: none and aria-disabled), and a short note under the label
   names the phase it opens in. The note itself stays fully legible - it is
   the information the row exists to give. */
.motor-theme #screen-game .nav-list .nav-item.nav-item-locked { cursor: default; }
.motor-theme #screen-game .nav-list .nav-item.nav-item-locked > a {
  opacity: .48;
  filter: blur(.6px);
}
.motor-theme #screen-game .nav-list .nav-item.nav-item-locked > a > span:first-child::before { opacity: .45; }
.motor-theme #screen-game .nav-list .nav-item .nav-locked-note {
  position: relative;
  display: block;
  margin: -3px 12px 7px 32px;
  padding-left: 14px;
  color: #8fa3b8;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .03em;
  line-height: 1.3;
}
/* A small padlock drawn from two pieces in the note's colour - no emoji. */
.motor-theme #screen-game .nav-list .nav-item .nav-locked-note::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 5px;
  margin-top: -1.5px;
  background: currentColor;
  border-radius: 1.5px;
}
.motor-theme #screen-game .nav-list .nav-item .nav-locked-note::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  width: 3px;
  height: 3px;
  margin-top: -4.5px;
  border: 1.5px solid currentColor;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
}

/* ---------- 2. one calm card grammar on Your forecourt --------------------- */

/* The grid: cards at a steady, readable width instead of stretching to fill
   whatever the row has left. A 4:3 photograph fills a 360px card well; a card
   stretched to 500px shows a small photograph in a field of white. */
.motor-theme .customer-orders-grid.is-motor {
  grid-template-columns: repeat(auto-fill, minmax(300px, 372px));
  gap: 14px;
  align-items: start;
}

.motor-theme .customer-orders-grid.is-motor > .customer-order-card {
  position: relative;
  background: var(--mpc-surface);
  border: 1px solid var(--mpc-line);
  border-radius: 14px;
  padding: 14px 16px 16px;
  box-shadow: 0 1px 2px rgba(16, 26, 40, 0.05);
}
/* The cafe's gold and teal tints told the two card kinds apart by colour
   alone. The heading on the card says which it is; the tint goes. */
.motor-theme .customer-orders-grid.is-motor > .motor-sourcing-card,
.motor-theme .customer-orders-grid.is-motor > .motor-customer-order-card { border-color: var(--mpc-line); }
.motor-theme .customer-orders-grid.is-motor > .motor-sourcing-card--incoming { background: var(--mpc-surface); }

/* Whose move it is, from the card's own data-turn-label, in one pill at the
   top of the card. app.js writes the attribute through
   MotorUiMarketplace.markCard; a card without it shows no pill. */
.motor-theme .customer-order-card[data-turn-label]::before {
  content: attr(data-turn-label);
  display: inline-block;
  max-width: 100%;
  margin: 0 0 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
  background: var(--mpc-grey-bg);
  color: var(--mpc-grey-ink);
}
.motor-theme .customer-order-card.mp-turn-you::before { background: var(--mpc-accent); color: #ffffff; }
.motor-theme .customer-order-card.mp-turn-role::before { background: var(--mpc-amber-bg); color: var(--mpc-amber-ink); }
.motor-theme .customer-order-card.mp-turn-other::before { background: var(--mpc-grey-bg); color: var(--mpc-grey-ink); }
.motor-theme .customer-order-card.mp-turn-done::before { background: var(--mpc-green-bg); color: var(--mpc-green-ink); }
.motor-theme .customer-order-card.mp-turn-you { border-color: var(--mpc-accent-line); box-shadow: 0 0 0 1px var(--mpc-accent-line) inset; }

/* The photograph: whole vehicle, its own 4:3 ratio, contain on white, capped
   by WIDTH and never by height (docs/motor-ui/PRODUCT-PHOTO-RULE.md). Every
   forecourt card leads with it the same way - the incoming trade request
   used to carry a 96x72 thumbnail beside its heading while the customer card
   next to it carried a 232px hero. */
.motor-theme .customer-orders-grid.is-motor .motor-order-product {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 10px;
}
.motor-theme .customer-orders-grid.is-motor .motor-order-product > div { padding-top: 0; }
.motor-theme .customer-orders-grid.is-motor img.motor-product-hero,
.motor-theme .customer-orders-grid.is-motor img.motor-product-photo {
  display: block;
  width: min(100%, 320px);
  height: auto;
  aspect-ratio: 4 / 3;
  margin: 0 auto;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--mpc-line);
  border-radius: 12px;
}
.motor-theme .customer-orders-grid.is-motor .customer-order-customer {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--mpc-ink);
  margin-bottom: 2px;
}
.motor-theme .customer-orders-grid.is-motor .customer-order-service {
  font-size: 13px;
  color: var(--mpc-ink-soft);
}

/* The state sentence ("Contact Ava Fictional at Volt Motors and ask for a
   trade price.") stays a sentence: the pill above already carries the colour. */
.motor-theme .customer-orders-grid.is-motor .customer-order-status,
.motor-theme .customer-orders-grid.is-motor .customer-order-status--open {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--mpc-ink-soft);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

/* Figures: label left, figure right, tabular numerals, one hairline apart.
   A long value (the customer's own sentence) wraps under its label. */
.motor-theme .customer-orders-grid.is-motor .customer-order-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 2px 12px;
  padding: 5px 0;
  border-top: 1px solid var(--mpc-line-soft);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--mpc-ink);
  font-variant-numeric: tabular-nums;
}
.motor-theme .customer-orders-grid.is-motor .customer-order-line > strong:first-child {
  font-weight: 600;
  color: var(--mpc-ink-muted);
}
.motor-theme .customer-orders-grid.is-motor .customer-order-line .customer-order-figure {
  font-weight: 700;
  color: var(--mpc-ink);
}
.motor-theme .customer-orders-grid.is-motor .customer-order-line + .customer-order-line { border-top-color: var(--mpc-line-soft); }
.motor-theme .customer-orders-grid.is-motor .customer-order-line:last-of-type { border-bottom: 1px solid var(--mpc-line-soft); }

/* Buttons. The one action that binds the firm is solid teal; the field
   controls (Send quote, Send counteroffer, Set price) are outlined; Decline
   is a quiet text button. A disabled state is grey on grey and still 3:1. */
.motor-theme .customer-orders-grid.is-motor .customer-order-btn {
  margin-top: 12px;
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  background: var(--mpc-accent);
  border: 1px solid var(--mpc-accent);
  color: #ffffff;
}
.motor-theme .customer-orders-grid.is-motor .customer-order-btn:hover:not(:disabled) {
  background: var(--mpc-accent-strong);
  border-color: var(--mpc-accent-strong);
}
.motor-theme .customer-orders-grid.is-motor .customer-order-btn:disabled {
  background: var(--mpc-inset);
  border-color: var(--mpc-line);
  color: var(--mpc-grey-ink);
  cursor: not-allowed;
}
.motor-theme .customer-orders-grid.is-motor .customer-order-btn--quiet,
.motor-theme .customer-orders-grid.is-motor .customer-order-btn--quiet:hover:not(:disabled) {
  margin-top: 4px;
  min-height: 34px;
  background: transparent;
  border-color: transparent;
  color: var(--mpc-grey-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.motor-theme .customer-orders-grid.is-motor .motor-pricing-save {
  background: var(--mpc-surface);
  border: 1px solid var(--mpc-accent);
  color: var(--mpc-accent-strong);
  font-family: inherit;
  font-weight: 700;
  border-radius: 8px;
}
.motor-theme .customer-orders-grid.is-motor .motor-pricing-save:hover:not(:disabled) { background: var(--mpc-accent-soft); }
.motor-theme .customer-orders-grid.is-motor .motor-pricing-save:disabled {
  border-color: var(--mpc-line);
  color: var(--mpc-grey-ink);
  background: var(--mpc-inset);
}
.motor-theme .customer-orders-grid.is-motor .motor-pricing-control label {
  color: var(--mpc-ink-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.motor-theme .customer-orders-grid.is-motor .motor-pricing-input {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 700;
  color: var(--mpc-ink);
}
.motor-theme .customer-orders-grid.is-motor .motor-pricing-locked {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--mpc-inset);
  color: var(--mpc-ink-soft);
  font-size: 12.5px;
  font-weight: 600;
}

/* Accept, counter, decline as one column: Accept first and solid, the
   counteroffer in an inset panel, Decline last and quiet. */
.motor-theme .customer-orders-grid.is-motor .motor-sourcing-negotiation {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}
.motor-theme .customer-orders-grid.is-motor .motor-sourcing-negotiation .customer-order-btn { margin-top: 6px; }
.motor-theme .customer-orders-grid.is-motor .motor-sourcing-negotiation .motor-sourcing-control,
.motor-theme .customer-orders-grid.is-motor .motor-sourcing-control {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--mpc-inset);
}

/* The next-step banner ("What to do now") and the commit line keep their
   place under the figures, in the same ink. */
.motor-theme .customer-orders-grid.is-motor .motor-next-action { margin: 10px 0 0; }
.motor-theme .customer-orders-grid.is-motor .motor-commit-line { margin-top: 8px; font-size: 11.5px; }

/* The deal chat is the card's footer: it talks, it never moves money. */
.motor-theme .customer-orders-grid.is-motor .motor-deal-chat {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--mpc-line-soft);
}
.motor-theme .customer-orders-grid.is-motor .motor-deal-chat__title {
  color: var(--mpc-ink-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- 3. group headings that read as headings ------------------------ */
.motor-theme .customer-orders-grid.is-motor > .motor-stock-grouphead,
.motor-theme .mp-closed > .motor-stock-grouphead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 6px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--mpc-line);
}
.motor-theme .customer-orders-grid.is-motor > .motor-stock-grouphead:first-child { margin-top: 4px; }
.motor-theme .customer-orders-grid.is-motor > .motor-stock-grouphead strong,
.motor-theme .mp-closed > .motor-stock-grouphead strong {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--mpc-ink);
}
.motor-theme .customer-orders-grid.is-motor > .motor-stock-grouphead span,
.motor-theme .mp-closed > .motor-stock-grouphead span {
  flex: 0 1 auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--mpc-grey-bg);
  color: var(--mpc-grey-ink);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.4;
  text-align: right;
}
.motor-theme .mp-grouphead--act span { background: var(--mpc-accent-soft); color: var(--mpc-accent-strong); }

/* The closed list: what happened, one quiet row each, full width. */
.motor-theme .customer-orders-grid.is-motor > .mp-closed { grid-column: 1 / -1; }
.motor-theme .mp-closed__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--mpc-line);
  border-radius: 12px;
  background: var(--mpc-surface);
  overflow: hidden;
}
.motor-theme .mp-closed__row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 4px 16px;
  padding: 9px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--mpc-ink-soft);
  font-variant-numeric: tabular-nums;
}
.motor-theme .mp-closed__row + .mp-closed__row { border-top: 1px solid var(--mpc-line-soft); }
.motor-theme .mp-closed__what { font-weight: 700; color: var(--mpc-ink); }
.motor-theme .mp-closed__row--sold .mp-closed__what::before,
.motor-theme .mp-closed__row--closed .mp-closed__what::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: 1px;
  background: var(--mpc-grey-ink);
}
.motor-theme .mp-closed__row--sold .mp-closed__what::before { background: var(--mpc-accent); }

/* ---------- 4. tabs, guide box and empty state in the one accent ----------- */
.motor-theme #panel-market .market-subtab {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--mpc-line);
  background: var(--mpc-surface);
  color: var(--mpc-ink-soft);
}
.motor-theme #panel-market .market-subtab:hover { border-color: var(--mpc-accent-line); color: var(--mpc-accent-strong); }
.motor-theme #panel-market .market-subtab.is-active {
  background: var(--mpc-accent-soft);
  border-color: var(--mpc-accent);
  color: var(--mpc-accent-strong);
}
.motor-theme #market-orders-section > details.guide-box summary {
  color: var(--mpc-ink-soft);
  font-size: 12.5px;
}
/* The cafe hourglass and clock glyphs in the empty state are the only
   decorative characters left on the forecourt; the sentence stands alone. */
.motor-theme #customer-orders-list .empty-state .empty-icon { display: none; }
.motor-theme #customer-orders-list .empty-state {
  padding: 22px 16px;
  border: 1px dashed var(--mpc-line);
  border-radius: 12px;
  color: var(--mpc-ink-soft);
  font-size: 13px;
}
.motor-theme .motor-trade-hint {
  border-color: var(--mpc-accent-line);
  background: var(--mpc-accent-soft);
  color: var(--mpc-ink-soft);
  font-size: 11.5px;
}

/* Never wider than the screen: the content column clips a stray wide child
   instead of handing the whole page a horizontal scrollbar. */
.motor-theme #screen-game > .main-content { overflow-x: hidden; }

/* ---------- 5. the Finance desk's deal rows at laptop width ---------------
   The desk lays the live deals and the calculator side by side
   (styles.css .motor-finance-desk__grid, 1.55fr / 0.75fr). On a 1366 or 1440
   laptop the content column is about 1040-1140px, so the deals column lands
   near 640px - and the deal row itself is a five-column grid, which squeezed
   its first cell to about 60px: "Pentti Perala (NPC) needs Small van" came
   out one word per line, with the figures beside it. Measured on the CEO &
   Finance chair's own sheet, which is where a tutorial step now sends them.

   At these widths the calculator goes BELOW the deals rather than beside
   them: the deals are the work, the calculator is a scratchpad. Same markup,
   same controls, same numbers - only the column count changes. A wider screen
   keeps the side-by-side layout. */
@media (max-width: 1560px) {
  .motor-theme .motor-finance-desk__grid { grid-template-columns: minmax(0, 1fr); }
  .motor-theme .motor-deal-calculator { max-width: 520px; }
}
/* And the row keeps a readable first cell whatever the column does: the
   vehicle and the firm on one line each, the figures wrapping under them
   instead of crushing the sentence. */
.motor-theme .motor-finance-deal-row {
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(78px, max-content)) auto;
}
@media (max-width: 1100px) {
  .motor-theme .motor-finance-deal-row {
    grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(78px, max-content));
    row-gap: 8px;
  }
  .motor-theme .motor-finance-deal-row__actions { grid-column: 1 / -1; justify-content: flex-start; }
}
