/*
 * report.css: the market study (report.html), on screen and printed as its PDF (server/pdf.mjs prints this
 * same page; the @media print part at the end is what makes it A4 pages).
 *
 * The survey-plan look of the rest of the site: a white page on the paper-coloured background, hairline
 * rules, tabular numbers, one dark rule where each chapter starts, survey-flag pink only for the prices.
 * Colours and sizes come from tokens.css; the chart's colours are its --chart-* tokens.
 */

.report-page { height: auto; min-height: 100%; background: var(--sheet); }

.report-status { max-width: 36rem; margin: 30vh auto 0; padding: 0 var(--space-4); text-align: center; color: var(--ink-muted); }
.report-status[data-kind="error"] { color: var(--warn); }

/* ------------------------------------------------------------------ The bar (screen only) */

.report-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  padding: calc(var(--space-2) + env(safe-area-inset-top, 0px)) var(--space-4) var(--space-2);
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}
.report-bar__end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* ------------------------------------------------------------------ The page */

.report-paper {
  max-width: var(--report-width);
  margin: var(--space-5) auto var(--space-6);
  padding: var(--space-6) var(--report-gutter);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  line-height: 1.6;
}
.report-paper p + p { margin-top: var(--space-2); }
.report-paper h2 {
  margin: var(--space-6) 0 var(--space-4);
  padding-top: var(--space-3);
  border-top: 2px solid var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-title);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
}
.report-paper h3 {
  margin: var(--space-5) 0 var(--space-2);
  font-family: var(--font-display);
  font-weight: 650;
  font-size: var(--text-lg);
  line-height: 1.3;
}
.report-paper h4 { margin: var(--space-4) 0 var(--space-2); font-size: var(--text-sm); font-weight: 650; }

.report-prose p { margin-top: var(--space-2); max-width: 70ch; text-wrap: pretty; }
.report-note { margin-top: var(--space-2); font-size: var(--text-sm); color: var(--ink-muted); }
.report-stats { margin-top: var(--space-3); font-size: var(--text-sm); font-weight: 550; font-variant-numeric: tabular-nums; }
.report-list { margin: var(--space-2) 0 0; padding-left: 1.2rem; }
.report-list li + li { margin-top: var(--space-1); }
.cite { font-size: 0.82em; color: var(--ink-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cite a { color: inherit; }

.report-banner {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-card);
  background: var(--badge-wait-bg);
  color: var(--badge-wait-text);
  font-size: var(--text-sm);
  font-weight: 600;
}
.report-banner--draft { background: var(--badge-bad-bg); color: var(--warn); }

/* ------------------------------------------------------------------ Cover */

.report-cover__kind { font-size: var(--text-sm); font-weight: 650; color: var(--flag-text); }
.report-cover__title {
  margin-top: var(--space-1);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-figure);
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.report-cover__subtitle { margin-top: var(--space-2); color: var(--ink-muted); }
.report-cover__headline {
  margin-top: var(--space-4);
  max-width: 42ch;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-lg);
  line-height: 1.35;
  text-wrap: pretty;
}
.report-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  margin: var(--space-5) 0 0;
  border-top: 2px solid var(--ink);
}
.report-figure { padding: var(--space-3) var(--space-3) var(--space-3) 0; border-bottom: 1px solid var(--line); }
.report-figure dt { font-size: var(--text-xs); color: var(--ink-muted); }
.report-figure dd {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-title);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.report-figure--accent dd { color: var(--flag-text); }
.report-cover__points { margin-top: var(--space-5); }
.report-cover__label { margin-bottom: var(--space-1); font-size: var(--text-xs); font-weight: 650; color: var(--ink-muted); }
.report-cover__meta { margin-top: var(--space-4); font-size: var(--text-sm); color: var(--ink-muted); }
.report-cover__meta p + p { margin-top: 2px; }

/* ------------------------------------------------------------------ Contents */

.report-contents ol { columns: 2 16rem; column-gap: var(--space-6); margin: 0; padding: 0; list-style: none; }
.report-contents li { padding: var(--space-1) 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.report-contents a { color: inherit; text-decoration: none; }
.report-contents a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ Tables */

.table-wrap { margin-top: var(--space-3); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.report-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.report-table th,
.report-table td { padding: 0.45rem 0.75rem 0.45rem 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.report-table thead th { border-bottom: 1px solid var(--ink); font-size: var(--text-xs); font-weight: 600; color: var(--ink-muted); white-space: nowrap; }
.report-table tbody th { font-weight: 600; white-space: nowrap; }
.report-table__date { white-space: nowrap; }
.report-table .num { text-align: right; white-space: nowrap; }
.report-table th:last-child,
.report-table td:last-child { padding-right: 0; }
.report-table__strong { font-weight: 650; }
.report-table__title { min-width: 11rem; }
.report-table--compact { width: auto; min-width: 16rem; }
.report-table--listings { font-size: var(--text-xs); }

/* ------------------------------------------------------------------ Maps (src/staticmap.js) and plans */

.report-figure-block { margin: var(--space-4) 0 0; break-inside: avoid; }
.staticmap {
  position: relative;
  overflow: hidden;
  width: 100%;
  background: var(--map-void);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.staticmap--site { height: 20rem; }
.staticmap--site.staticmap--many { height: 30rem; } /* many lots (src/site-report.js, src/report.js): more room to name them */
.staticmap--location { height: 16rem; }
.staticmap__tile { position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; }
.staticmap__overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.staticmap__lot { fill: var(--parcel-fill); stroke: var(--parcel-stroke); stroke-width: 2.5; stroke-linejoin: round; }
.staticmap__label { font-family: var(--font-body); font-weight: 700; font-size: 12px; fill: var(--label-text); paint-order: stroke; stroke: var(--parcel-casing); stroke-width: 3px; stroke-linejoin: round; }
.staticmap__marker { fill: var(--parcel-stroke); stroke: var(--parcel-casing); stroke-width: 3; }
.staticmap__halo { fill: var(--parcel-fill); stroke: var(--parcel-stroke); stroke-width: 1.5; }
.staticmap__scale-bg { fill: var(--sheet); opacity: 0.9; }
.staticmap__scale { stroke: var(--ink); stroke-width: 2; }
.staticmap__scale-text { font: 600 10px var(--font-body); fill: var(--ink); }
.report-caption { margin-top: var(--space-1); font-size: var(--text-xs); color: var(--ink-muted); }

.report-sketches { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
.report-sketch { margin: 0; break-inside: avoid; }

/* ------------------------------------------------------------------ The price chart (src/chart.js) */

.chart { margin: var(--space-4) 0 0; break-inside: avoid; }
.chart__title { margin-bottom: var(--space-2); font-size: var(--text-sm); font-weight: 650; }
.chart__box { position: relative; padding: var(--space-2) 0 0; background: var(--chart-surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart__axis { stroke: var(--ink-muted); stroke-width: 1; }
.chart__divider { stroke: var(--ink-muted); stroke-width: 1; stroke-dasharray: 3 3; } /* between the listings, today's prices and those once permitted */
.chart__tick,
.chart__axis-label { font: 500 10.5px var(--font-body); fill: var(--ink-muted); font-variant-numeric: tabular-nums; }
.chart__group { font: 650 12px var(--font-body); fill: var(--ink); }
.chart__lane { font: 500 11px var(--font-body); fill: var(--ink-muted); }
/* Words in the chart get a halo in the chart's background, so a line passing behind them doesn't cut them. */
.chart__group, .chart__lane, .chart__value, .chart__reference-label {
  paint-order: stroke;
  stroke: var(--chart-surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.chart__dot { fill: var(--chart-listing); stroke: var(--chart-surface); stroke-width: 2; }
.chart__range { fill: var(--chart-range); }
.chart__value { font: 650 11px var(--font-body); fill: var(--ink); font-variant-numeric: tabular-nums; }
.chart__reference { stroke: var(--chart-reference); stroke-width: 1.5; }
.chart__reference-label { font: 600 10.5px var(--font-body); fill: var(--chart-reference); }
.chart__hit { fill: transparent; outline: none; }
.chart__hit:hover,
.chart__hit:focus-visible { stroke: var(--ink-muted); stroke-width: 1; }
.chart__tip {
  position: absolute;
  z-index: 2;
  max-width: calc(100% - 2 * var(--space-2));
  padding: var(--space-1) var(--space-2);
  transform: translate(-50%, -100%);
  background: var(--ink);
  color: var(--sheet);
  border-radius: var(--radius-control);
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* ------------------------------------------------------------------ Uses (chapters 4 and 6) */

.use-list { margin: var(--space-3) 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); counter-reset: use; }
.use-list__item { padding: var(--space-3) 0; border-bottom: 1px solid var(--line); counter-increment: use; break-inside: avoid; }
.use-list__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: var(--space-3); }
.use-list__title { font-weight: 650; }
.use-list__title::before { content: counter(use) ". "; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.use-list__price { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.use-list__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4em; margin-top: 2px; font-size: var(--text-xs); color: var(--ink-muted); }

.use-cards--report { grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); }
.use-card__details { margin: var(--space-2) 0 0; font-size: var(--text-sm); }
.use-card__details div + div { margin-top: var(--space-2); }
.use-card__details dt { font-size: var(--text-xs); font-weight: 650; color: var(--ink-muted); }
.use-card__details dd { margin: 0; text-wrap: pretty; }

/* ------------------------------------------------------------------ Sources */

.sources { margin: var(--space-2) 0 0; padding: 0; list-style: none; font-size: var(--text-sm); }
.sources__item {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
  break-inside: avoid;
  scroll-margin-top: 5rem;
}
.sources__item:target { background: var(--badge-wait-bg); }
.sources__number { font-weight: 650; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.sources__title { display: block; font-weight: 550; }
.sources__meta { display: block; font-size: var(--text-xs); color: var(--ink-muted); }
.sources__url { display: block; font-size: var(--text-xs); color: var(--ink); overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ Phones */

@media (max-width: 47.5rem) {
  .report-bar { position: static; } /* on a phone the bar would take too much of the screen to stay */
  .report-paper { margin: 0; padding: var(--space-5) var(--space-4) var(--space-6); border: 0; border-radius: 0; }
  .report-figure dd { font-size: var(--text-lg); }
  .report-cover__title { font-size: calc(var(--text-figure) * 0.72); }
  .report-paper h2 { font-size: calc(var(--text-title) * 0.9); }
  .staticmap--site { height: 15rem; }
  .staticmap--site.staticmap--many { height: 24rem; }
  .staticmap--location { height: 13rem; }
  .report-bar .control--solid { padding: 0 var(--space-3); }
}

/* ------------------------------------------------------------------ Printed (the PDF) */

/* The same margins as MARGIN in server/pdf.mjs; the page numbers go in the bottom one. */
@page { size: A4; margin: 16mm 15mm 17mm; }

@media print {
  .no-print { display: none !important; }
  .report-page { background: var(--paper); }
  .report-paper { max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; font-size: var(--text-print); line-height: 1.5; }
  .report-paper h2 { margin-top: 0; }
  a { color: inherit; text-decoration: none; }
  .sources__url { text-decoration: underline; }

  /* The cover fills page one; the contents and chapter 1 share page two; every other chapter starts a page. */
  .report-cover { display: flex; flex-direction: column; min-height: 257mm; break-after: page; }
  .report-cover__meta { margin-top: auto; padding-top: var(--space-4); }
  .report-cover .staticmap--site { height: 88mm; }
  .staticmap--site.staticmap--many, .report-cover .staticmap--site.staticmap--many { height: 125mm; }
  .report-chapter { break-before: page; }
  #ch-scope { break-before: auto; }

  h2, h3, h4 { break-after: avoid; }
  .report-table tr, .use-card, .use-list__item, .sources__item, .chart, .report-figure-block, .report-sketch, .report-figures { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .report-table--listings { font-size: var(--text-print-small); }
  .report-contents ol { columns: 1; }
  .chart__tip { display: none !important; }
  .report-banner, .staticmap, .sdg-chip, .impact-dot, .chart { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
