/* ITAD Price Index, the bits the rest of the site has no use for.
   Everything else on the page is style.css, verify.css and business.css, in that order, so this
   file only has to carry the index figure, the reference table and the blank-cell treatment. */

.idx-figure {
  margin: 10px 0 2px;
  font-family: var(--heading-font);
  font-size: 2.6rem;
  line-height: 1;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: var(--heading-tracking);
}

.idx-figure--gap {
  font-size: 1.25rem;
  color: var(--muted);
  font-weight: 600;
}

.idx-move {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

/* Direction is never carried by colour alone: each one also says the word, so the figure survives
   being read in greyscale, by somebody colour blind, or out loud by a screen reader. */
.idx-up { color: var(--good); }
.idx-down { color: var(--bad); }
.idx-flat { color: var(--muted); }

.idx-card--gap { border-style: dashed; }

.idx-blank {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
  white-space: nowrap;
}

.idx-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.idx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 520px;
}

.idx-table th,
.idx-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.idx-table th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-soft);
  vertical-align: bottom;
}

/* The grade headings are sentences, so they are allowed to wrap. Holding them on one line pushed
   the three price columns wide enough to squeeze the model name into four lines, which is how a
   table of eight phones ended up taller than the panel above it. */
.idx-table th:first-child,
.idx-table td:first-child {
  min-width: 172px;
  white-space: normal;
}

.idx-table .r { white-space: nowrap; }

/* ...but the rule above also catches the header cells, which carry the same class, so the grade
   headings were held on one line after all and the comment above was describing an intention the
   stylesheet did not carry out. Three sentence length headings on one line made the reference
   table 750px wide inside a 582px panel, so at 1280px a reader saw Model, the good condition
   price, and half of the fair condition one: Faulty and Buyers were off screen with only a
   scrollbar to say so. Letting the headings wrap brings the table to 580px and all five columns
   into view. Prices keep nowrap. */
.idx-table th.r { white-space: normal; }

.idx-table tbody tr:last-child td { border-bottom: 0; }
.idx-table td { color: var(--text); }
.idx-table .r { text-align: right; }

.idx-outro {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
}

.idx-outro a { color: var(--accent-text); font-weight: 600; }

@media (max-width: 640px) {
  .idx-figure { font-size: 2.1rem; }
  .idx-table th,
  .idx-table td { padding: 9px 11px; }
}

/* The grade spread is the one figure on the page a reader is likely to quote back, so it is
   allowed to look like a statement rather than another line of body copy. */
.mode-card p.idx-spread {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}

/* Below 680px neither table fits, so each row becomes its own card and the column heading travels
   with the value as data-label.

   Measured at 375px before this was written, not assumed: the wrapper is 269px (body 375, then
   .quote-section padding 24 each side, then .panel padding 28 each side), the three column table
   needs 278px at its natural minimum and the five column one needs 528px. So the wide table could
   not be squeezed into a phone by any amount of padding or font work, and the overflow-x scroll it
   fell back on put every price off screen at rest: a reader saw a column of model names, a thin
   scrollbar, and no figures at all.

   680 rather than 640 because the panel chrome costs 104px, so the 528px table needs a 632px
   viewport and 640 would leave 8px of headroom. Above the breakpoint the wrapper keeps its
   overflow-x, so 640 to 680 behaves exactly as it does today. */
@media (max-width: 680px) {
  .idx-table-wrap {
    overflow-x: visible;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .idx-table {
    display: block;
    min-width: 0;
    font-size: 0.9rem;
  }

  .idx-table thead { display: none; }
  .idx-table tbody { display: block; }

  .idx-table tbody tr {
    display: block;
    padding: 11px 14px 13px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
  }

  .idx-table tbody tr:last-child { margin-bottom: 0; }

  /* The value cells carry their heading on the left and their figure on the right. Both are flex
     items, which is the whole point: the figure is a bare text node, so it becomes an anonymous
     item and sits opposite the label instead of running on after it. flex-wrap is there for the
     "not enough buyers" case, where a long heading and a long value cannot share one line. */
  .idx-table tbody td {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 4px 14px;
    padding: 5px 0;
    border-bottom: 0;
    text-align: left;
  }

  /* .idx-table .r sets nowrap and outscores a plain tbody td selector, so the heading and its
     value inherited nowrap inside the card. Nothing overflows at today's wording, which is
     exactly why this needed measuring rather than reading: a longer grade label, or the
     "not enough buyers" that a blank cell renders, would have spilled out of the card with
     nothing to show for it. */
  .idx-table tbody td[data-label] { white-space: normal; }

  .idx-table tbody td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  /* The model name is the card's heading, so it takes no label and is not a flex row. */
  .idx-table tbody tr td:first-child {
    display: block;
    min-width: 0;
    margin-bottom: 5px;
    padding: 0 0 9px;
    border-bottom: 1px solid var(--border);
    font-size: 0.98rem;
    font-weight: 600;
  }
}

/* A past edition says so at the top, before any figure can be read as current. The same block
   carries the live case, where it says the opposite: this address is permanent, the page is not. */
.idx-past-note {
  margin: 0 0 22px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  /* --accent-text is #ffffff in this theme, the same as the body text, so it accents nothing
     here. --accent-dark is the colour this page already gives a link inside body copy. */
  border-left: 3px solid var(--accent-dark);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

.idx-past-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.idx-past-note strong {
  color: var(--text-strong);
  font-weight: 600;
}

/* One line per edition. A list rather than a row of pills, so it reads the same at any width and
   stays legible however many months accumulate. */
.idx-editions {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.idx-editions li + li {
  border-top: 1px solid var(--border);
}

/* The page already has a body-link colour, set in business.css as
     [data-theme="business"] section p:not(.hero-actions) a { color: var(--accent-dark) }
   which reaches a link in a paragraph and not one in a list item, so it is named here rather
   than inherited. Not var(--accent-text): that is #ffffff in this theme, identical to the body
   text, and with the underline suppressed as well these read as plain text. The underline is
   left to the page. */
.idx-editions a {
  display: block;
  padding: 11px 2px;
  color: var(--accent-dark);
  font-size: 0.97rem;
  font-weight: 500;
}

/* ---- What the market pays today ------------------------------------------------------------
   The live buy side block. Everything here is rendered into the HTML by
   scripts/render-market-index.mjs before deploy, so it reads and indexes with scripting off; the
   script only adds the ticker motion and the device lookup on top. ---------------------------- */

/* The ticker.
   One run is written into the HTML and the client clones it, so with scripting off this is a
   single readable row that simply does not move. It carries no arrows and claims no direction:
   there is one week of this feed, so there is no movement to report, and the range between the
   best and worst buyer on the same day is the better story anyway. */
.mkt-ticker {
  margin: 0 0 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
  overflow: hidden;
  /* Fades the ends rather than cutting them, so a part scrolled item does not read as a typo. */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 48px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 48px, #000 calc(100% - 48px), transparent);
}
.mkt-ticker-track { display: flex; width: max-content; }
.mkt-ticker-run { display: flex; flex: none; }
/* Added by the script once it has cloned the run, so a static page never animates a single copy
   off its own edge and leaves a blank strip. */
.mkt-ticker[data-running="1"] .mkt-ticker-track { animation: mkt-scroll 90s linear infinite; }
.mkt-ticker[data-running="1"]:hover .mkt-ticker-track { animation-play-state: paused; }
@keyframes mkt-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .mkt-ticker[data-running="1"] .mkt-ticker-track { animation: none; }
  .mkt-ticker { overflow-x: auto; }
}

.mkt-tick {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  padding: 11px 20px;
  white-space: nowrap;
  font-size: 0.82rem;
  border-right: 1px solid var(--border);
}
.mkt-tick-name { font-weight: 600; }
.mkt-tick-grade {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.mkt-tick-range { font-weight: 700; color: var(--good); }
.mkt-tick-books { font-size: 0.74rem; color: var(--muted); }

/* The lookup. Shares .search-box and .suggestions with the rest of the site. */
.mkt-search { max-width: 560px; margin: 0 auto 24px; }
.mkt-search > label {
  display: block;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
.mkt-search .suggestions { max-height: 320px; overflow-y: auto; }
.mkt-search .suggestions button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
}
.mkt-search .suggestions button:last-child { border-bottom: 0; }
.mkt-search .suggestions button.is-active { background: var(--accent-soft); }
.mkt-opt-name { font-weight: 600; }
.mkt-opt-sub { grid-column: 1; font-size: 0.78rem; color: var(--muted); }
.mkt-opt-price {
  grid-row: 1 / span 2; grid-column: 2; align-self: center;
  font-weight: 700; color: var(--good); white-space: nowrap;
}
.mkt-note { margin: 10px 0 0; font-size: 0.78rem; line-height: 1.6; color: var(--muted); text-align: center; }

/* A looked up device. Deliberately has no ClearFrank figure on it: this page publishes the market
   and nothing of ours, which is the whole reason it can be cited. */
.mkt-card {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  text-align: left;
}
.mkt-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.mkt-card-head strong { font-size: 1rem; }
.mkt-card-tag {
  flex: none; font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.mkt-grade-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 4px 14px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.mkt-grade-row:last-of-type { border-bottom: 0; }
.mkt-grade-name { font-weight: 600; }
.mkt-grade-avg { font-weight: 700; font-size: 1.05rem; color: var(--good); white-space: nowrap; }
.mkt-grade-meta { grid-column: 1 / -1; font-size: 0.76rem; color: var(--muted); }
.mkt-card-foot { margin: 12px 0 0; font-size: 0.76rem; line-height: 1.65; color: var(--muted); }
.mkt-card-foot a { color: var(--accent); font-weight: 600; }

.mkt-method { margin-top: 20px; }
.mkt-method p { font-size: 0.82rem; line-height: 1.7; color: var(--muted); margin: 0 0 10px; }
.mkt-method strong { color: var(--text); }
.mkt-method a { color: var(--accent); font-weight: 600; }

@media (max-width: 560px) {
  .mkt-tick { padding: 10px 14px; gap: 7px; }
  .mkt-grade-row { grid-template-columns: 1fr auto; }
}
