/* Lumber chart widget. Loaded after site.css. */

.lc { width: 100%; }   /* fills its column; the page that holds it sets the width */

/* ----- Price at the top ----- */
.readout {
  padding: 14px 18px 12px;
  background: var(--cream);
  border-left: 6px solid var(--orange);
}
.readout p { margin: 0; }
.readout-label { font-size: 0.9rem; font-weight: bold; text-transform: uppercase; letter-spacing: 0.04em; }
.readout-date { font-family: var(--serif); font-size: 1.25rem; font-weight: bold; }
.readout-price strong {
  color: var(--orange-text);
  font-size: 3.6rem;
  line-height: 1.05;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.readout-price span { font-size: 1rem; font-weight: bold; margin-left: 6px; }
.readout-change { font-size: 0.95rem; }
.readout-meta { margin-top: 4px !important; font-size: 0.8rem; font-style: italic; }

/* ----- Price readout inside the chart box (top left) -----
   Resting: small and mostly see-through, just the price and the week. On hover or keyboard focus it turns
   solid and shows the rest (what the price is, the full date, the change, when the chart was updated).
   On narrow screens there is no room to float it, so it sits above the icons, always showing everything. */
.chart-box { position: relative; }
.chart-box .readout {
  position: absolute; top: 6px; left: 8px; z-index: 10;
  max-width: calc(100% - 190px);
  padding: 2px 12px 4px;
  border-left: 5px solid var(--orange);
  border-radius: 0 4px 4px 0;
  background: rgba(253, 251, 225, 0.6);
  transition: background 0.15s, box-shadow 0.15s;
}
.chart-box .readout:hover, .chart-box .readout:focus, .chart-box .readout:focus-within {
  background: var(--cream);
  box-shadow: 0 4px 16px rgba(54, 26, 0, 0.3);
  min-width: 270px;
}
.readout-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; }
.chart-box .readout-price strong { font-size: 2rem; line-height: 1.15; }
.chart-box .readout-price span { font-size: 0.8rem; margin-left: 2px; }
.readout-short { font-size: 0.85rem; font-weight: bold; }
.readout-more { max-height: 0; opacity: 0; overflow: hidden; transition: opacity 0.15s; }
.chart-box .readout:hover .readout-more, .chart-box .readout:focus .readout-more, .chart-box .readout:focus-within .readout-more {
  max-height: 220px; opacity: 1; padding-top: 4px; border-top: 1px solid var(--rule); margin-top: 4px;
}
/* Esc closes the open card (same as the tooltips) until the pointer or focus moves again */
.tips-off .chart-box .readout .readout-more { max-height: 0; opacity: 0; padding: 0; margin: 0; border: 0; }
.tips-off .chart-box .readout { background: rgba(253, 251, 225, 0.6); box-shadow: none; min-width: 0; }
@media (max-width: 560px) {
  .chart-box .readout, .chart-box .readout:hover, .chart-box .readout:focus, .chart-box .readout:focus-within {
    position: static; max-width: none; min-width: 0; margin: 2px 2px 8px; padding: 6px 12px 8px;
    background: var(--cream); box-shadow: none;
  }
  .readout-short { display: none; }
  .readout-more, .chart-box .readout:hover .readout-more, .tips-off .chart-box .readout .readout-more {
    max-height: none; opacity: 1; overflow: visible; padding: 0; margin: 0; border: 0;
  }
  .chart-box .readout-price strong { font-size: 3rem; }
}

/* ----- Chart ----- */
.chart-box {
  margin-top: 12px;
  padding: 8px 8px 4px;
  background: var(--cream);
}
.chart { width: 100%; height: 340px; }
.chart-caption { margin: 4px 6px 4px; font-size: 0.85rem; font-style: italic; min-height: 3em; }

/* ----- Slider ----- */
.scrub {
  margin-top: 12px;
  padding: 12px 18px 14px;
  background: var(--cream);
}
.scrub label.scrub-title { display: block; margin-bottom: 6px; font-weight: bold; }
.scrub-row { display: flex; align-items: center; gap: 8px; }

.scrub input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  margin: 0;
  background: transparent;
  accent-color: var(--orange-bar);
  cursor: pointer;
}

.scrub-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-top: 8px; }
.scrub-tools .field { display: flex; align-items: center; gap: 8px; }
.scrub-tools .field label { font-weight: bold; }
.scrub-tools input[type="date"] {
  min-height: 40px;
  padding: 4px 8px;
  border: 2px solid var(--brown);
  border-radius: 4px;
  background: #fff;
  color: var(--brown);
  font: 1rem var(--sans);
}
.scrub-tools .btn { padding: 6px 14px; min-height: 40px; }
.scrub-tools [hidden] { display: none; }

/* ----- Table alternative ----- */
.tablebox { margin-top: 16px; max-height: 520px; overflow: auto; }
.tablebox .weeks th { position: sticky; top: 0; z-index: 1; }
.weeks { width: 100%; border-collapse: collapse; font-size: 0.95rem; background: var(--cream); }
.weeks caption { text-align: left; font-size: 0.9rem; font-weight: bold; padding: 8px 10px 6px; }
.weeks th, .weeks td { padding: 6px 10px; border-bottom: 1px solid var(--rule); text-align: left; }
.weeks th { background: var(--brown); color: #fff; font-family: var(--serif); }
.weeks td:nth-child(n+2), .weeks th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
.weeks tr.sel td { font-weight: bold; background: #f6e8bf; }

.basis { margin: 16px 0 0; font-size: 0.85rem; }
.basis p { margin: 0 0 6px; }

/* Same space under the logo as the homepage (its notice box has a 14px top margin). */
.lc[data-mode="view"] > h1.bar { margin-top: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 4px; }

.status { margin: 12px 0; padding: 12px 16px; background: var(--cream); border-left: 6px solid var(--orange); }

/* ----- Print page ----- */
.printpage { max-width: 8in; margin: 0 auto; padding: 24px; background: #fff; color: #000; }
.printpage .bar { clip-path: none; }
.printpage .readout, .printpage .chart-box, .printpage .weeks { background: #fff; }
.printpage .readout { border-left-color: #000; }
.printpage .readout-price strong { color: #000; }
.printpage .chart { height: 300px; }
.printpage h1 { font-family: var(--serif); margin: 8px 0 2px; }
.printpage .printed { margin: 0 0 12px; font-size: 0.9rem; }

@media (max-width: 700px) {
  .readout-price strong { font-size: 3rem; }
  .chart { height: 260px; }
}
/* Narrow screens: the date and the change line can wrap to two lines, so always leave room for two.
   (Measured with every week in the history from 320px wide up.) */
@media (max-width: 560px) {
  .readout-date { min-height: 3em; }
  .readout-change { min-height: 3em; }
}
@media (max-width: 640px) {
  .chart-caption { min-height: 9em; }
}
@media (max-width: 400px) {
  .chart-caption { min-height: 12em; }
}

@media print {
  @page { margin: 0.5in; }
  body, .frame, .panel, .printpage { background: #fff !important; color: #000; }
  .frame { margin: 0; padding: 0; width: auto; max-width: none; }
  .panel { padding: 0; }
  .noprint, .scrub, .actions, .foot { display: none !important; }
  .printpage { padding: 0; }
  .weeks th { background: #000 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .weeks tr.sel td { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

body.printbody { background: #fff; }


/* ----- Chart drawing (inline SVG made by chart.js) ----- */
.th-range { margin-left: 6px; font: normal 0.8rem var(--sans); }
.chart svg { display: block; width: 100%; height: 100%; }
.ch-grid { stroke: #e8dfc0; stroke-width: 1; }
.ch-axis { stroke: #8a7560; stroke-width: 1; }
.ch-line { fill: none; stroke: #652e00; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { fill: #cf5f0c; stroke: #fdfbe1; stroke-width: 2; }
.ch-txt { fill: #361a00; font: 13px Helvetica, Arial, sans-serif; }
.ch-hover-line { stroke: #8a7560; stroke-width: 1; stroke-dasharray: 3 3; }
.ch-hover-dot { fill: #652e00; }
.ch-hover-txt { fill: #361a00; font: bold 13px Helvetica, Arial, sans-serif; paint-order: stroke; stroke: #fdfbe1; stroke-width: 4px; stroke-linejoin: round; }
.ch-cover { cursor: pointer; }
.printpage .ch-grid { stroke: #ddd; }
.printpage .ch-axis { stroke: #000; }
.printpage .ch-line, .printpage .ch-dot, .printpage .ch-hover-dot { stroke: #000; }
.printpage .ch-line { stroke-width: 2.5; }
.printpage .ch-dot { fill: #000; stroke: #fff; }
.printpage .ch-txt, .printpage .ch-hover-txt { fill: #000; }
.printpage .ch-hover-txt { stroke: #fff; }

/* ----- Icon buttons ----- */
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  border: 2px solid var(--brown); border-radius: 4px;
  background: var(--cream); color: var(--brown); cursor: pointer;
}
.iconbtn:hover { background: #fff; }
.iconbtn[data-show="bar"] .ico-line, .iconbtn[data-show="line"] .ico-bar { display: none; }
.iconbtn:disabled { opacity: 0.4; cursor: not-allowed; background: var(--cream); }
/* A toggle that is switched on is filled in, so it is clear at a glance (the page also says it in words). */
.iconbtn[aria-pressed="true"] { background: var(--brown); color: var(--cream); }
.iconbtn[aria-pressed="true"]:hover { background: var(--brown-mid); }
.chart-tools { display: flex; justify-content: flex-end; gap: 8px; padding: 2px 4px 6px; }

/* ----- Tooltips (CSS only; show on hover and on keyboard focus; Esc hides them) ----- */
.tip { position: relative; display: inline-flex; }
.tip-grow { flex: 1 1 auto; min-width: 0; }
.tip-grow input[type="range"] { width: 100%; }
.tip::after {
  content: attr(data-tip);
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 260px;
  padding: 6px 10px; margin-bottom: 0;
  /* the transparent bottom border keeps the pointer "on" the tip while moving from the control to it */
  border-bottom: 8px solid transparent; background-clip: padding-box;
  background: var(--brown); color: #fff;
  font: 0.85rem/1.3 var(--sans); text-align: left; white-space: normal;
  border-radius: 4px;
  opacity: 0; visibility: hidden; z-index: 20;
  transition: opacity 0.12s;
}
.tip:hover::after, .tip:focus-within::after { opacity: 1; visibility: visible; }
.tip-left::after { left: 0; transform: none; }
.tip-right::after { left: auto; right: 0; transform: none; }
.tips-off .tip::after { opacity: 0; visibility: hidden; }

/* ----- Bar chart ----- */
.ch-bar { fill: #9b5a26; }
.ch-bar-sel { fill: #cf5f0c; }
.ch-bar-txt { fill: #fff; font: bold 12px Helvetica, Arial, sans-serif; text-anchor: middle; }
.ch-bar-prior { fill: #ead7ae; stroke: #652e00; stroke-width: 1; }
.ch-bar-prior.ch-thin { stroke: none; fill: #b28650; }  /* 3.1:1 on the cream background */   /* very thin bars: an outline would hide the fill */
.ch-line-prior { fill: none; stroke: #9b5a26; stroke-width: 2.5; stroke-dasharray: 7 5; stroke-linejoin: round; }
.ch-leg-txt { fill: #361a00; font: 13px Helvetica, Arial, sans-serif; }

/* Year bands: two alternating tones. The text is dark brown on a light tone (about 10:1 or better). */
.ch-band-0 { fill: #efe2b8; }
.ch-band-1 { fill: #e0c993; }
.ch-band-sep { stroke: #9a7f4f; stroke-width: 1; stroke-dasharray: 2 4; }
.ch-band-txt, .ch-band-avg { fill: #361a00; text-anchor: middle; font: 12px Helvetica, Arial, sans-serif; }
.ch-band-avg { font-weight: bold; }
.printpage .ch-bar-prior { fill: #fff; stroke: #000; }
.printpage .ch-line-prior { stroke: #444; }
.printpage .ch-band-0 { fill: #eee; }
.printpage .ch-band-1 { fill: #d4d4d4; }
.printpage .ch-band-txt, .printpage .ch-band-avg, .printpage .ch-leg-txt { fill: #000; }
.printpage .ch-bar { fill: #888; }
.printpage .ch-bar-sel { fill: #000; }

@media (max-width: 700px) {
  .tip::after { max-width: 200px; }
}
.print-only { display: none; }
@media print {
  .tablebox { max-height: none; overflow: visible; }
  .tip::after, .chart-tools { display: none !important; }
  .print-only { display: block; }
  .printed { margin: 0 0 8px; font-size: 0.9rem; }
  /* The chart page: keep the logo, title, price, chart, table and the basis note. Everything else goes. */
  .lc .bar { background: none; color: #000; clip-path: none; padding-left: 0; border-bottom: 2px solid #000; }
  .lc .readout, .lc .chart-box, .lc .weeks { background: #fff; }
  /* The price block prints as its own box above the chart, fully open, so the numbers and the graph are separate. */
  .chart-box .readout {
    position: static; max-width: none; min-width: 0; margin: 0 0 18px; padding: 10px 16px 12px;
    background: #fff; box-shadow: none; border: 2px solid #000; border-left-width: 8px; border-radius: 0;
  }
  .readout-short { display: none; }
  .readout-more, .tips-off .chart-box .readout .readout-more { max-height: none; opacity: 1; overflow: visible; padding: 0; margin: 0; border: 0; }
  .chart-box .readout-price strong { font-size: 3rem; }
  .lc .chart { border: 1px solid #000; }
  .lc .readout { border-left-color: #000; }
  .lc .readout-price strong { color: #000; }
  .lc .readout-meta { display: none; }
  .lc .chart { height: 300px; }
  .lc .chart-box, .lc .readout, .lc .weeks tr { break-inside: avoid; }
  .lc .ch-grid { stroke: #ddd; }
  .lc .ch-axis { stroke: #000; }
  .lc .ch-txt, .lc .ch-hover-txt, .lc .ch-band-txt, .lc .ch-band-avg, .lc .ch-leg-txt { fill: #000; }
  .lc .ch-band-0 { fill: #eee; }
  .lc .ch-band-1 { fill: #d4d4d4; }
  .lc .ch-line { stroke: #000; }
  .lc .ch-dot { fill: #000; stroke: #fff; }
  .lc .ch-bar { fill: #888; }
  .lc .ch-bar-sel { fill: #000; }
  .lc .ch-bar-prior { fill: #fff; stroke: #000; }
  .lc .ch-line-prior { stroke: #444; }
  .th-range { color: #fff; }
  a[href]::after { content: none !important; }
}
