/* Article: removing outliers from plant sensor data. Shared tokens and the header, footer, chips and buttons come from /site.css. */

/* cover: the article's core in its tray */
.tray { margin-top: clamp(8px, 2vw, 20px); }
.tray .ticks {
  height: 12px;
  background:
    repeating-linear-gradient(to right, rgb(var(--ink) / .55) 0 1px, transparent 1px 60px) left bottom / 100% 12px no-repeat,
    repeating-linear-gradient(to right, rgb(var(--ink) / .28) 0 1px, transparent 1px 12px) left bottom / 100% 6px no-repeat;
}
.tray .cover { display: block; width: 100%; height: clamp(56px, 9vw, 96px); object-fit: cover; background: rgb(var(--sand-light)); }
.traymeta { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 10px 0 0; }
.traymeta b { color: rgb(var(--brand)); font-weight: 600; }
.tagrow { margin-top: 12px; }

.opening { padding: clamp(20px, 4vw, 40px) 0 clamp(8px, 2vw, 16px); }
.opening h1 { margin: 0; max-width: 20ch; font-size: clamp(32px, 5.4vw, 58px); line-height: 1.02; letter-spacing: -.038em; font-weight: 700; text-wrap: balance; }
.intro { margin: 10px 0 0; max-width: 40ch; font-size: clamp(18px, 2.4vw, 23px); line-height: 1.34; letter-spacing: -.012em; font-weight: 500; }
.intro mark { background: none; color: rgb(var(--brand)); white-space: nowrap; }
.facts { list-style: none; margin: clamp(26px, 4vw, 44px) 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 28px; border-top: 1px solid rgb(var(--ink)); }
.facts li { padding: 14px 0 16px; border-bottom: 1px solid rgb(var(--ink) / .14); font-size: 15px; line-height: 1.45; }
.facts li span { display: block; margin-bottom: 4px; }

section.block > h2 { max-width: 22ch; }

/* the trend panel: a historian screen */
.trend { margin-top: clamp(22px, 4vw, 36px); background: rgb(var(--ink)); color: rgb(var(--paper)); }
.trend-head, .sheet-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; padding: 12px clamp(12px, 2.4vw, 20px); }
.trend-head { border-bottom: 1px solid rgb(var(--paper) / .14); }
.tagname, .readout { font: 500 12px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.trend .tagname { color: rgb(var(--paper) / .72); }
.trend .readout { color: rgb(var(--coral)); }
.plot { position: relative; padding: clamp(10px, 2vw, 16px); }
.plot picture, .plot img { display: block; width: 100%; height: auto; }
.plot img { background: rgb(var(--paper)); }
.plot.twin .legend { grid-column: 1 / -1; padding-bottom: 4px; }
.basis { margin: clamp(18px, 3vw, 28px) 0 0; }
.plot canvas { display: block; width: 100%; }
.plot.live-on { padding: 14px clamp(10px, 2vw, 18px) 8px 0; }
.plot .stage { position: relative; }
.plot .ax { position: absolute; font: 400 12px/1 var(--mono); color: rgb(var(--paper) / .78); white-space: nowrap; pointer-events: none; }
.plot .ax.y { transform: translate(-100%, -50%); padding-right: 8px; }
.plot .ax.x { transform: translate(-50%, 0); }
.plot .note { padding: 1px 5px; background: rgb(var(--ink) / .82); position: absolute; font: 500 12px/1.3 var(--sans); color: rgb(var(--paper) / .85); pointer-events: none; }
.plot .note.c { transform: translate(-50%, -100%); text-align: center; }
.plot .note.hot { color: rgb(var(--coral)); }
.plot .sub { margin: 0 0 3px; padding-left: 54px; font: 600 12.5px/1.3 var(--sans); color: rgb(var(--paper) / .9); }
.plot .cap { margin: 0 0 8px; padding-left: 54px; min-height: 2.7em; font: 400 12px/1.35 var(--sans); color: rgb(var(--coral)); }
.plot.twin.live-on { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 2px 0 10px 54px; font: 400 12.5px/1.3 var(--sans); color: rgb(var(--paper) / .84); }
.legend i { display: inline-block; width: 14px; height: 3px; margin-right: 7px; vertical-align: middle; border-radius: 2px; background: currentColor; }
.legend .band { height: 10px; border-radius: 2px; }

.controls { display: flex; flex-wrap: wrap; gap: 14px 30px; padding: 12px clamp(12px, 2.4vw, 20px) 16px; }
.controls[hidden] { display: none; }
.trend > .controls { border-bottom: 1px solid rgb(var(--paper) / .14); }
.ctl { display: grid; gap: 8px; }
.trend .ctl .label { color: rgb(var(--paper) / .62); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.chips button { padding: 9px 15px; border: 1px solid rgb(var(--ink) / .25); border-radius: 999px; background: transparent; color: inherit; font: 600 13px/1 var(--sans); cursor: pointer; transition: background .2s ease, color .2s ease, border-color .2s ease; }
.chips.small button { padding: 7px 12px; font-size: 12px; }
.trend .chips button { border-color: rgb(var(--paper) / .32); }
.trend .chips button:hover { border-color: rgb(var(--paper)); }
.trend .chips button[aria-pressed="true"] { background: rgb(var(--coral)); border-color: rgb(var(--coral)); color: rgb(var(--ink)); }
.chips button:focus-visible { outline: 2px solid rgb(var(--coral)); outline-offset: 2px; }
.trend-head .controls, .sheet-head .controls { padding: 0; }

.says { margin: 16px 0 0; max-width: 62ch; padding-left: 14px; border-left: 3px solid rgb(var(--brand)); font-size: clamp(15.5px, 1.9vw, 17.5px); line-height: 1.5; }

.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 44px; margin-top: clamp(22px, 4vw, 36px); }
#raw .pair { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.pair h3 { margin: 0 0 6px; font-size: 17px; letter-spacing: -.01em; }
.pair p { margin: 0 0 12px; max-width: 46ch; color: rgb(var(--ink) / .78); font-size: 15.5px; }

/* the hourly averages: one cell under each hour of the trend */
.avgs { display: grid; gap: 14px; margin: 16px 6px 8px 54px; }
.srow p { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; margin: 0 0 6px; font: 400 12px/1.35 var(--sans); color: rgb(var(--paper) / .75); }
.srow p b { font: 500 12px/1.5 var(--mono); letter-spacing: .04em; color: rgb(var(--paper)); }
.cells { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; }
.cells span { display: grid; place-items: center; min-height: 34px; border-radius: 2px; background: rgb(var(--paper) / .09); color: rgb(var(--paper) / .9); font: 500 12px/1 var(--mono); font-variant-numeric: tabular-nums; }
.cells b { font-weight: inherit; }
.cells i { font-style: normal; }
.cells .blank b { visibility: hidden; }
.cells .over { background: rgb(var(--coral)); color: rgb(var(--ink)); font-weight: 700; }
.cells .quiet, .cells .fixed { box-shadow: inset 0 0 0 1.5px rgb(var(--coral)); color: rgb(var(--coral)); }
.cells .blank { background: rgb(var(--paper) / .04); }

/* the shift report as a table: shown only when the script has not run */
.plot .sheet { color: rgb(var(--ink)); }
.sheet { margin-top: clamp(22px, 4vw, 36px); border: 1px solid rgb(var(--ink) / .22); background: #fff; }
.sheet-head { background: rgb(var(--sand-light)); border-bottom: 1px solid rgb(var(--ink) / .22); }
.sheet .tagname { color: rgb(var(--ink) / .72); }
.sheet table { width: 100%; border-collapse: collapse; font: 400 14px/1 var(--mono); font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { padding: 9px clamp(8px, 2vw, 16px); border-bottom: 1px solid rgb(var(--ink) / .1); text-align: left; font-weight: 400; }
.sheet thead th { font: 500 11.5px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: rgb(var(--ink) / .74); border-bottom-color: rgb(var(--ink) / .22); }
.sheet th[scope="row"] { white-space: nowrap; }
.sheet td.n { white-space: nowrap; }
.sheet tbody th { width: 3.5em; color: rgb(var(--ink) / .62); border-right: 1px solid rgb(var(--ink) / .1); }
.sheet .n { width: 5.5em; text-align: right; }
.sheet tr.over .n:not(.t) { color: rgb(var(--brand)); font-weight: 600; }
.sheet tfoot th, .sheet tfoot td { border-top: 1px solid rgb(var(--ink)); border-bottom: 0; font-weight: 600; padding-top: 12px; padding-bottom: 12px; }
.sheet tfoot th { font-family: var(--sans); font-size: 13px; }
.sheet .t { color: rgb(var(--ink) / .62); }
.sheet tr.wrong { background: rgb(var(--coral) / .16); }
.sheet tr.wrong td.t:last-child { color: rgb(var(--brand)); font-weight: 600; }

/* what to do */
.matrix-wrap { margin-top: clamp(20px, 4vw, 34px); overflow-x: auto; }
.matrix { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 14.5px; line-height: 1.4; }
.matrix th, .matrix td { padding: 13px 14px 13px 0; text-align: left; vertical-align: top; border-bottom: 1px solid rgb(var(--ink) / .14); font-weight: 400; }
.matrix thead th { font: 500 12px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: rgb(var(--ink) / .78); border-bottom: 1px solid rgb(var(--ink)); }
.matrix tbody th { width: 27%; font-weight: 600; }
.matrix td { color: rgb(var(--ink) / .74); }
.k { display: block; margin-bottom: 2px; font-weight: 700; color: rgb(var(--ink)); }
.k::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: rgb(var(--ink) / .35); }
.k.remove::before { background: rgb(var(--brand)); }
.k.repair::before { background: rgb(var(--coral)); }
.k.keep::before { background: rgb(var(--olive)); }
.k.flag::before { background: transparent; box-shadow: inset 0 0 0 2px rgb(var(--ink)); }

.checks { list-style: none; counter-reset: c; margin: clamp(20px, 4vw, 34px) 0 0; padding: 0; border-top: 1px solid rgb(var(--ink)); }
.checks li { counter-increment: c; display: grid; grid-template-columns: clamp(44px, 8vw, 76px) 1fr; padding: 16px 0; border-bottom: 1px solid rgb(var(--ink) / .14); color: rgb(var(--ink) / .76); font-size: 15.5px; }
.checks li::before { content: counter(c, decimal-leading-zero); grid-row: span 2; font: 500 13px/1.7 var(--mono); color: rgb(var(--brand)); }
.checks b { display: block; color: rgb(var(--ink)); font-size: clamp(17px, 2.4vw, 21px); letter-spacing: -.012em; font-weight: 600; }

.method .pair p b { color: rgb(var(--ink)); }
.repo { margin: 6px 0 0; max-width: 62ch; font-size: 14.5px; color: rgb(var(--ink) / .7); }

.cta { margin-top: clamp(44px, 9vw, 96px); padding: clamp(24px, 5vw, 52px); background: rgb(var(--ink)); color: rgb(var(--paper)); }
.cta .label { color: rgb(var(--paper) / .72); }
.cta h2 { margin: 8px 0 0; max-width: 20ch; font-size: clamp(26px, 4.4vw, 42px); line-height: 1.08; letter-spacing: -.03em; font-weight: 600; text-wrap: balance; }
.cta p { margin: 14px 0 22px; max-width: 44ch; color: rgb(var(--paper) / .72); }
.cta .btn { background: rgb(var(--brand)); color: #fff; }
.cta .btn:hover { background: rgb(var(--coral)); color: rgb(var(--ink)); }

@media (max-width: 600px) {
  .plot.twin.live-on { grid-template-columns: 1fr; }
  .matrix { min-width: 0; }
  .matrix thead { position: absolute; left: -10000px; }
  .matrix tr, .matrix th, .matrix td { display: block; width: auto; border: 0; padding: 0; }
  .matrix tr { padding: 16px 0; border-bottom: 1px solid rgb(var(--ink) / .14); }
  .matrix tbody th { width: auto; margin-bottom: 10px; font-size: 16px; }
  .matrix td { display: grid; grid-template-columns: 10.5em 1fr; gap: 0 14px; padding: 5px 0; }
  .matrix td::before { content: attr(data-label); font: 500 11.5px/1.5 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: rgb(var(--ink) / .74); grid-row: span 2; }
  .matrix td .k { grid-column: 2; }
  .sheet .n { width: 4.6em; }
  .cells span { min-height: 52px; }
  .cells b { writing-mode: vertical-rl; transform: rotate(180deg); }
  .sheet thead .t { font-size: 9.5px; }
}
@media (prefers-reduced-motion: reduce) { .chips button { transition: none; } }
