/* Product Policies: the picker, the legend, and the row of policy junctures.
 *
 * This file carries only what is new on this page. The page shell, the title
 * block, the folded how-to block and every form field come from
 * budget-machine.css, which this page links first, so a field here is exactly
 * the same height and shape as a field on the budget pages rather than a
 * near-match that drifts.
 */

/* ---- the picker ---- */

.pp-picker { margin: 0 0 1.1rem; }
.pp-picker-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}
/* The fields come from budget-machine.css at 2.4rem; the only change here is
 * removing the bottom margin a stacked field carries, because these three sit
 * in a row and their labels already line up. */
.pp-picker-row .bm-field { margin-bottom: 0; min-width: 0; }
.pp-picker-note {
  margin: 0.55rem 0 0;
  font-size: 0.84rem;
  color: var(--bm-muted);
  min-height: 1.2rem;
}
.pp-picker-note:empty { display: none; }

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

/* ---- the chosen product's heading ---- */

.pp-product-head {
  background: var(--bm-white);
  border: 1px solid var(--bm-border);
  border-left: 4px solid var(--bm-accent);
  border-radius: var(--bm-radius);
  padding: 1rem 1.1rem;
  margin: 0 0 1rem;
  box-shadow: var(--bm-shadow);
}
.pp-product-head h2 { margin: 0 0 0.3rem; font-size: 1.25rem; line-height: 1.3; }
.pp-product-why { margin: 0 0 0.6rem; font-size: 0.95rem; color: var(--bm-muted); }
.pp-product-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
  color: var(--bm-muted);
}
.pp-product-facts strong { color: var(--bm-text); }
.pp-source {
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
  color: var(--bm-light);
}

/* Which rung of the price ladder the product's price is, and the warning that
 * the figures a policy sets sit on a different rung. The warning is bordered
 * rather than quiet: it corrects a reading a person has very likely already
 * made by the time they reach it. */
.pp-level { margin: 0 0 0.5rem; font-size: 0.9rem; }
.pp-level-warning {
  margin: 0 0 0.6rem;
  padding: 0.6rem 0.75rem;
  border-left: 3px solid var(--bm-accent);
  background: var(--bm-subtle);
  border-radius: var(--bm-radius);
  font-size: 0.9rem;
}

/* ---- the price record, for a product with no researched chain ---- */

.pp-chart-card {
  background: var(--bm-white);
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius);
  padding: 0.95rem 1.05rem;
  margin: 0 0 0.75rem;
}
.pp-chart-card h3 { margin: 0 0 0.6rem; font-size: 1.05rem; }

/* The line is drawn with preserveAspectRatio="none" so it fills whatever width
 * it is given, and the stroke carries vector-effect="non-scaling-stroke" so
 * stretching the box never thickens or thins the line. */
.pp-chart { margin: 0 0 0.6rem; }
.pp-chart svg {
  display: block;
  width: 100%;
  height: 170px;
  overflow: visible;
}
.pp-chart-ends {
  display: flex;
  justify-content: space-between;
  margin: 0.25rem 0 0;
  font-family: var(--bm-mono);
  font-size: 0.78rem;
  color: var(--bm-muted);
}

/* ---- one policy juncture ---- */

.pp-timeline { margin: 0; padding: 0; list-style: none; }

.pp-juncture {
  background: var(--bm-white);
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius);
  padding: 0.95rem 1.05rem;
  margin: 0 0 0.75rem;
}

.pp-juncture-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  margin: 0 0 0.3rem;
}
.pp-date {
  font-family: var(--bm-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bm-accent);
  white-space: nowrap;
}
.pp-price {
  font-family: var(--bm-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--bm-text);
  white-space: nowrap;
}
.pp-change { font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.pp-change.is-up { color: #b91c1c; }
.pp-change.is-down { color: #15803d; }
.pp-change.is-flat { color: var(--bm-light); }

.pp-title { margin: 0 0 0.2rem; font-size: 1.04rem; line-height: 1.35; }
.pp-title a { color: var(--bm-accent); }
.pp-number {
  margin: 0 0 0.55rem;
  font-family: var(--bm-mono);
  font-size: 0.8rem;
  color: var(--bm-muted);
}

.pp-figures {
  margin: 0 0 0.55rem;
  padding: 0.6rem 0.75rem;
  background: var(--bm-subtle);
  border-radius: var(--bm-radius);
  list-style: none;
  font-size: 0.88rem;
}
.pp-figures li { margin: 0 0 0.25rem; }
.pp-figures li:last-child { margin-bottom: 0; }
.pp-figures-source { margin: 0.4rem 0 0; font-size: 0.78rem; color: var(--bm-light); }

.pp-written {
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bm-light);
}
.pp-para { margin: 0 0 0.6rem; font-size: 0.93rem; }
.pp-para:last-child { margin-bottom: 0; }
.pp-para-label { font-weight: 700; color: var(--bm-text); }

.pp-note {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--bm-light);
}
.pp-extra { margin: 0.45rem 0 0; font-size: 0.85rem; }
.pp-extra a { color: var(--bm-accent); }

.pp-flag {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #fef08a;
  color: #713f12;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ---- recent notices ---- */

.pp-recent { margin: 1.2rem 0 0; }
.pp-recent h3 { margin: 0 0 0.2rem; font-size: 1.05rem; }
.pp-recent-note { margin: 0 0 0.6rem; font-size: 0.84rem; color: var(--bm-muted); }
.pp-recent-list { margin: 0; padding: 0; list-style: none; }
.pp-recent-list li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--bm-border);
  font-size: 0.88rem;
}
.pp-recent-date {
  font-family: var(--bm-mono);
  font-size: 0.8rem;
  color: var(--bm-muted);
  margin-right: 0.5rem;
}
.pp-recent-list a { color: var(--bm-accent); }
.pp-recent-agency { display: block; font-size: 0.78rem; color: var(--bm-light); }

/* ---- the legend ---- */

.pp-legend {
  margin: 1.4rem 0 0;
  background: var(--bm-white);
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius);
  padding: 0.8rem 1rem;
}
.pp-legend > summary { cursor: pointer; font-size: 0.96rem; }
.pp-legend-body { margin-top: 0.7rem; }
.pp-legend-list { margin: 0; padding: 0; list-style: none; }
.pp-legend-list li {
  padding: 0.5rem 0;
  border-top: 1px solid var(--bm-border);
  font-size: 0.89rem;
}
.pp-legend-list li:first-child { border-top: 0; }
.pp-legend-name { font-weight: 700; display: block; }
.pp-legend-expect { color: var(--bm-muted); }
.pp-legend-count { color: var(--bm-light); font-size: 0.8rem; }

/* ---- the dark theme ----
 *
 * Only the colours that must change are repeated here, so a colour has exactly
 * one definition in the light theme and one override when it genuinely needs a
 * different value in the dark.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pp-change.is-up { color: #fca5a5; }
  :root:not([data-theme="light"]) .pp-change.is-down { color: #86efac; }
  :root:not([data-theme="light"]) .pp-flag { background: #713f12; color: #fef08a; }
}

/* ---- the floating levers panel ----
 *
 * Fixed to the bottom right, and minimising puts it flat on the bottom edge of
 * the window as a single bar, which is what was asked for: out of the way
 * without being gone, and in the same place every time so it can be found
 * again without hunting.
 */

.pl-for { margin: 0.1rem 0 0; font-size: 0.8rem; color: var(--bm-muted); }

.pl-notes-lede {
  margin: 0.5rem 0 0;
  font-size: 0.76rem;
  color: var(--bm-muted);
}

.pl-ing { border-top: 1px solid var(--bm-border); padding-top: 0.4rem; margin-top: 0.5rem !important; }
/* One line per food a person really buys, so the money is read off against a
   price they recognise rather than as a bare percentage. */
.pl-food-list { margin: 0.35rem 0 0 0; padding-left: 1.1rem; }
.pl-food-list li { font-size: 0.82rem; line-height: 1.45; margin-bottom: 0.3rem; }
.pl-bill { border-top: 1px solid var(--bm-border); padding-top: 0.4rem;
  margin-top: 0.5rem !important; font-weight: 700; }

/* The amount a price is for, said beside every price the page draws. */
.pp-per { font-size: 0.78rem; font-weight: 400; color: var(--bm-muted); }

/* Under 1100px there is not room for the bar beside the panel, so it is lifted
   above it instead.

   The number comes from measuring rather than guessing. The bar holds a slot
   for Stop whether it is available or not, which is what keeps it one width
   through the reading cycle, and that makes it about 491px. The panel and its
   gap are 25rem, or 400px. 491 + 400 is 891, so both fit on one line from about
   1000px and not below it. Two earlier numbers here were wrong because they
   were worked out against a different bar width each time, which is why this
   one is stated with the arithmetic that produced it. */
@media (max-width: 999px) {
  .pr-bar { bottom: calc(0.6rem + var(--pp-panel-height, 0px)); }
}

/* From 1000px there is room, so the bar is centred in the strip to the left of
   the panel instead of in the whole window. Measured before this: at 1280px the
   bar ran into the panel by 80px once it was reading, and at 1024px it
   overlapped by 100px even at rest, with both at the same z-index, so which one
   covered the other came down to which script loaded first. */
@media (min-width: 1000px) {
  .pr-bar {
    left: calc((100vw - 25rem) / 2);
    transform: translateX(-50%);
  }
}

/* The product's own price, at the top of the panel.
 *
 * It is there because a reader took a lever's 6.35 dollars a bushel for the
 * price of flour, on a page where flour costs 54.5 cents a pound. A large
 * number in dollars beside a product priced in cents reads as that product's
 * price however carefully the label says bushel, so the real price is now
 * stated before any lever is, and every lever set in another unit says what it
 * comes to in the product's own.
 */
.pl-nowprice {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.6rem;
  background: var(--bm-subtle);
  border-left: 3px solid var(--bm-accent);
  border-radius: var(--bm-radius);
  font-size: 0.86rem;
}
.pl-same {
  margin: 0.3rem 0 0;
  font-family: var(--bm-mono);
  font-size: 0.78rem;
  color: var(--bm-accent);
}
.pl-same:empty { display: none; }

/* How the thing a policy prices relates to the thing a person buys. Without
   this line a wheat price by the bushel was read as the price of flour. */
.pl-connection {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.6rem;
  background: var(--bm-white);
  border: 1px solid var(--bm-border-dark);
  border-radius: var(--bm-radius);
  font-size: 0.84rem;
}

/* The link to the producer's own page, near the top of a product's view.
   The product page says what policy does to a price; that page says what the
   thing costs to produce. Neither is complete without the other. */
.pp-grower-link {
  border-left: 3px solid var(--bm-accent);
  padding: 0.4rem 0 0.4rem 0.6rem;
  margin: 0.5rem 0 0.8rem;
  font-size: 0.9rem;
}

/* The products a page covers, folded away until a reader opens one.
   A fold-out in the flow of the page rather than a pop-out, because the levers
   panel is fixed over the bottom right and really does cover things there. */
.pp-covered { margin: 1.5rem 0; }
.pp-covered h3 { margin: 0 0 0.4rem; }
.pp-covered-why { margin: 0 0 0.8rem; color: var(--bm-muted); }
.pp-covered-item {
  margin: 0 0 0.5rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius);
  background: var(--bm-white);
}
.pp-covered-item summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.pp-covered-tag {
  font-family: var(--bm-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: #e8f3ea;
  color: #1b5e20;
}
.pp-covered-tag.is-gone { background: var(--bm-subtle); color: var(--bm-muted); }
.pp-covered-body { margin-top: 0.5rem; line-height: 1.6; }
.pp-covered-body p { margin: 0; }
