/*
 * The report document: the edit view's preview and the printed PDF (specs/008-pdf-reports research
 * D2). Ported from references/mockup-customer-report.html, keeping only what the report uses. It is
 * inlined into the document by layouts/report, which links nothing, so a report prints the same
 * anywhere and the app's Tailwind build can never restyle it.
 *
 * Every rule is scoped to .report-document, the document's <body>: `stylesheet_link_tag :app` links
 * every stylesheet in this directory into the app's pages too, where unscoped table rules would
 * restyle them.
 *
 * Printed texts are never transformed: the watermark reads in capitals because the locale text is
 * written so (FR-009).
 */

@page {
  size: A4;
}

.report-document {
  --ink: #14151a;
  --ink-soft: #4a4d55;
  --gray: #8a8e96;
  --line: #e7e8ec;
  --canvas: #eceef1;
  --red: #e63323;
  --green: #1e9e5a;
  --amber: #e8a213;
  --strip-up: #10b981;
  --strip-downtime: #dc2626;
  --strip-excluded: #6ee7b7;
  --strip-no-data: #d1d5db;

  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", "Liberation Sans", Arial, sans-serif;
  font-size: 10.5pt;
  line-height: 1.45;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.report-document *,
.report-document *::before,
.report-document *::after {
  box-sizing: border-box;
}

.report-document .report {
  position: relative;
}

/*
 * The printable width is a fractional number of pixels, and Chromium cuts a box's right border
 * drawn on its last one: an inset of a pixel keeps every box's frame whole.
 */
@media print {
  .report-document .report {
    padding: 0 1px;
  }
}

/* The preview is not paged: one sheet on a grey canvas. */
@media screen {
  .report-document {
    background: var(--canvas);
    padding: 24px 12px;
  }

  .report-document .report {
    max-width: 760px;
    margin: 0 auto;
    padding: 48px 52px 56px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(20, 21, 26, 0.14), 0 2px 6px rgba(20, 21, 26, 0.08);
  }

  /*
   * The watermark is the PDF's (FR-009). On screen it only gets in the way of reading; the cover's
   * status line says it is a draft. Hidden, not left out, so preview and PDF stay one HTML.
   */
  .report-document .watermark {
    display: none;
  }
}

/* Behind the content, on every printed page: Chromium repeats fixed elements per page. */
.report-document .watermark {
  position: fixed;
  top: 42%;
  left: 0;
  right: 0;
  z-index: 0;
  text-align: center;
  font-size: 86pt;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.08);
  transform: rotate(-30deg);
  pointer-events: none;
}

.report-document .report > :not(.watermark) {
  position: relative;
  z-index: 1;
}

/* Cover */
.report-document .cover {
  padding-bottom: 6px;
}

.report-document .eyebrow {
  color: var(--red);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  margin: 0 0 8px;
}

.report-document .cover h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* The period and the status, below the title and quieter than it. */
.report-document .cover .sub {
  margin: 4px 0 0;
  color: var(--gray);
  font-size: 0.78rem;
}

.report-document .cover .sub + .sub {
  margin-top: 0;
}

.report-document .idbox {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
  margin-top: 18px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.76rem;
  color: var(--gray);
}

/* The report's id on the left, the time zone on the right. */
.report-document .idbox > div:last-child {
  margin-left: auto;
  text-align: right;
}

.report-document .idbox b {
  display: block;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.8rem;
}

/* A result as a bar like the cover's box, on one line, its items separated by vertical lines. */
.report-document .bar {
  display: flex;
  margin-top: 10px;
  padding: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.76rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  break-inside: avoid;
}

.report-document .bar > div {
  flex: 0 1 auto;
  padding: 0 12px;
}

.report-document .bar > div + div {
  border-left: 1px solid var(--line);
}

.report-document .bar > div.wide {
  flex: 1 1 auto;
}

.report-document .bar b {
  display: block;
  margin-bottom: 2px;
  color: var(--gray);
  font-weight: 600;
  font-size: 0.66rem;
}

.report-document .bar strong {
  font-weight: 700;
}

/* Chapters and sections */
.report-document h2.sec {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 30px 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
  break-after: avoid;
}

.report-document h2.sec .no {
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 700;
}

.report-document h3 {
  margin: 22px 0 4px;
  font-size: 1rem;
  font-weight: 700;
  break-after: avoid;
}

.report-document h4 {
  margin: 14px 0 4px;
  font-size: 0.85rem;
  font-weight: 700;
  break-after: avoid;
}

.report-document .secsub {
  margin: 0 0 10px;
  font-size: 0.76rem;
  color: var(--gray);
}

.report-document p {
  margin: 0 0 6px;
}

/* Tables */
.report-document table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.report-document th {
  padding: 6px 7px;
  border-bottom: 1.5px solid var(--ink);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--gray);
  text-align: left;
  vertical-align: bottom;
}

.report-document td {
  padding: 6px 7px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

.report-document tr {
  break-inside: avoid;
}

/* A downtime's annotation, a full-width line under its row and kept on its page
   (specs/012-uptime-event-annotations research D12). */
.report-document tr:has(+ tr.annotation) {
  break-after: avoid;
}

.report-document tr:has(+ tr.annotation) td {
  padding-bottom: 2px;
  border-bottom: none;
}

.report-document tr.annotation td {
  padding-top: 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.report-document .num {
  text-align: right;
  white-space: nowrap;
}

.report-document .marker {
  display: block;
  font-size: 0.68rem;
  color: var(--gray);
}

/* Verdicts are words; the colour only repeats them. */
.report-document .ok {
  color: var(--green);
  font-weight: 600;
}

.report-document .bad {
  color: var(--red);
  font-weight: 600;
}

.report-document .muted {
  color: var(--gray);
}

.report-document .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: -1px;
}

.report-document .dot.ok {
  background: var(--green);
}

.report-document .dot.bad {
  background: var(--red);
}

/* Hints and notes */
.report-document .notice {
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid var(--amber);
  border-radius: 8px;
  background: #fdf6e7;
  font-size: 0.74rem;
  color: var(--ink-soft);
  break-inside: avoid;
}

.report-document .notice b {
  color: var(--ink);
}

.report-document .footnote {
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--gray);
}

.report-document .box {
  margin-top: 10px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.76rem;
  color: var(--ink-soft);
  break-inside: avoid;
}

.report-document .box dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 3px 14px;
  margin: 6px 0 0;
}

.report-document .box dt {
  color: var(--gray);
}

.report-document .box dd {
  margin: 0;
  color: var(--ink);
}

.report-document ul.plain {
  margin: 4px 0 0;
  padding-left: 16px;
}

.report-document .comment p {
  margin: 0 0 6px;
}

/* Availability strips: up, downtime, hatched no data. */
.report-document .tl {
  margin-top: 12px;
  break-inside: avoid;
}

/* The strip's colours are the live strips' (Tailwind emerald-500, red-600, emerald-300, gray-300). */
.report-document .tl-bar {
  display: block;
  width: 100%;
}

.report-document .tl-bar .up rect {
  fill: var(--strip-up);
}

.report-document .tl-bar .downtime rect {
  fill: var(--strip-downtime);
}

.report-document .tl-bar .downtime rect.stripes {
  fill: url(#report-strip-downtime);
}

/* An excluded downtime: light green (Tailwind emerald-300) with the downtime's stripes
   (specs/012-uptime-event-annotations research D4). */
.report-document .tl-bar .excluded rect {
  fill: var(--strip-excluded);
}

.report-document .tl-bar .excluded rect.stripes {
  fill: url(#report-strip-downtime);
}

.report-document .tl-bar .no_data rect {
  fill: var(--strip-no-data);
}

.report-document svg.defs {
  position: absolute;
}

.report-document .tl-axis {
  position: relative;
  height: 14px;
  margin-top: 3px;
  font-size: 0.6rem;
  color: var(--gray);
}

.report-document .tl-axis span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.report-document .tl-axis span.first {
  transform: none;
}

.report-document .tl-axis span.last {
  transform: translateX(-100%);
}

.report-document .tl-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--ink-soft);
}

.report-document .tl-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Each state's swatch is a bar as the strip draws it. */
.report-document .tl-legend b {
  display: inline-block;
  width: 7px;
  height: 12px;
  border-radius: 1px;
  background: var(--strip-up);
}

.report-document .tl-legend b.downtime {
  background: repeating-linear-gradient(-45deg, transparent 0 2px, rgba(255, 255, 255, 0.45) 2px 4px), var(--strip-downtime);
}

.report-document .tl-legend b.excluded {
  background: repeating-linear-gradient(-45deg, transparent 0 2px, rgba(255, 255, 255, 0.45) 2px 4px), var(--strip-excluded);
}

.report-document .tl-legend b.no_data {
  background: linear-gradient(to top, var(--strip-no-data) 4px, transparent 4px);
}

/* One block per service. */
.report-document .service {
  margin-top: 18px;
  padding-top: 4px;
}

.report-document .nowrap {
  white-space: nowrap;
}

.report-document .monitors {
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--ink-soft);
}

.report-document .monitors b {
  color: var(--ink);
  font-weight: 600;
}
