/* UrbanQ report viewer, on the X+1 system.
 *
 * The values are read off xplus-studio.com, not invented, and they are the same
 * ones site.css uses - test_brand.py checks the two agree, because a landing
 * page and the tool it leads to drifting apart is the obvious failure here.
 *
 * The plan canvas stays a dark band in both themes. That is the studio's own
 * rhythm - paper page, full-bleed dark section - and it is also simply how a
 * drawing reads best: the geometry is the light on a dark ground, the way a
 * plot on a screen is not a plot on paper.
 */

:root {
  color-scheme: light;

  --ground: #F2F0EA;
  --surface: #FFFDF8;
  --surface-2: #EAE7DF;
  --line: #DDDDDD;
  --line-soft: #E7E4DC;
  --ink: #101010;
  --ink-2: #3C3C3C;
  --muted: #4F4F4F;

  --accent: #FF2B18;
  --accent-soft: #FFE4E0;

  /* Sequential, dark-canvas: a dim warm neutral rising to the accent, so the
     top of every scale is the one colour the system already owns. */
  --ramp-0: #3A3A38;
  --ramp-1: #6B5F4E;
  --ramp-2: #A8813C;
  --ramp-3: #D95E2B;
  --ramp-4: #FF2B18;

  --flag: #FF2B18;
  --ok: #4E9E6A;
  --none: #2E2E2E;

  --plan-bg: #111111;
  --plan-street: #4A4A4A;
  --plan-land: #3A4348;
  --plan-inner: #5A554E;

  --shadow: none;

  --step--1: 11px;
  --step-0: .92rem;
  --step-1: 1.05rem;
  --step-2: 1.5rem;
  --step-3: 2.2rem;

  --sans: "DM Sans", "Helvetica Neue", Arial, sans-serif;
  --display: var(--sans);
  --mono: "Space Mono", ui-monospace, Consolas, monospace;
}




:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0C0C0C;
  --surface: #141414;
  --surface-2: #1B1B1B;
  --line: rgba(255, 255, 255, .16);
  --line-soft: rgba(255, 255, 255, .10);
  --ink: #FFFDF8;
  --ink-2: rgba(255, 255, 255, .85);
  --muted: rgba(255, 255, 255, .62);

  --accent: #FF2B18;
  --accent-soft: #2A100C;

  --flag: #FF2B18;
  --ok: #5FB37C;
  --none: #2E2E2E;

  /* The canvas is already dark; it does not change with the theme. */
  --plan-bg: #0A0A0A;
  --plan-street: #4A4A4A;
  --plan-land: #3A4348;
  --plan-inner: #5A554E;

  --shadow: none;
}


* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--step-0)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .85rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.identity { display: flex; align-items: center; gap: .85rem; }

/* The mark, on both viewers. Never hidden at any width: this slot once carried
   the studio's wordmark, which a narrow screen could reasonably drop, and it
   now carries the product's own mark. */
.home {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  padding-right: .85rem;
  border-right: 1px solid var(--line);
}

.home svg { display: block; overflow: visible; }
a.home:hover { color: var(--accent); }

.identity h1 {
  margin: 0;
  font: 650 var(--step-1)/1 var(--display);
  letter-spacing: -.03em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font: 400 var(--step--1)/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Square, not a pill: the system has no rounded corners anywhere. */
.status {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .34rem .6rem;
  border: 1px solid var(--line);
  font: 400 var(--step--1)/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: none;
}

.status .dot { width: .45rem; height: .45rem; background: var(--muted); }

.status[data-state="live"] .dot { background: var(--ok); animation: pulse 2.4s ease-out infinite; }
.status[data-state="file"] .dot { background: var(--accent); }
.status[data-state="offline"] .dot { background: var(--muted); }
.status[data-state="working"] .dot { background: var(--ramp-2); animation: pulse 1s ease-out infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70% { box-shadow: 0 0 0 .5rem transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.btn {
  font: 400 var(--step--1)/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink);
  background: none;
  border: 1px solid var(--line);
  padding: .55rem .75rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.btn:hover { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.small { padding: .35rem .55rem; }
.select { font-family: var(--sans); }

/* ---------------------------------------------------------------- layout */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 1rem;
  padding: 1rem 1.25rem;
  align-items: start;
}

@media (max-width: 62rem) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* A band rather than a card. The studio's sections are full-bleed and squared,
   and a drawing does not want a rounded frame around it. */
.planwrap {
  background: var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 32rem;
}

.planhead {
  display: flex;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.modes { display: flex; gap: .25rem; flex-wrap: wrap; }

.mode {
  font: 400 var(--step--1)/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .5rem 0;
  margin-right: 1.1rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.mode:hover { color: var(--ink); }
.mode.is-on { color: var(--accent); border-bottom-color: var(--accent); }
.mode:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.planopts {
  display: flex;
  gap: .9rem;
  align-items: center;
  font: 400 var(--step--1)/1 var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-2);
  flex-wrap: wrap;
}

.check { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.check input { accent-color: var(--accent); }

.canvaswrap { position: relative; flex: 1; background: var(--plan-bg); min-height: 26rem; }
#plan { display: block; width: 100%; height: 100%; }

.empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  margin: 0; color: var(--muted);
  font-family: var(--mono); font-size: var(--step--1);
}
.empty[hidden] { display: none; }

/* Same rule as the legend below: this paragraph is absolutely positioned over
   the dark canvas, so it needs the light-on-dark colour rather than --muted.
   --muted is a paper-ground token; against #111 it lands near 2.3:1, which at
   this size made the one instruction on an empty viewer effectively invisible
   and the page read as though nothing had loaded. */
/* margin-inline:auto matters: the base rule pins this with inset:0, so a
   max-width alone collapses the box against the left edge instead of
   centring it. */
.empty {
  color: rgba(255, 255, 255, .85);
  max-width: 46ch; margin-inline: auto;
  text-align: center; line-height: 1.7; padding: 0 1.5rem;
}

/* On the dark canvas the legend and readout are light-on-dark whatever the
   page theme is, because the canvas does not change with it. */
.legend {
  position: absolute; left: .9rem; bottom: .9rem;
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .6rem;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .16);
  font: 400 var(--step--1)/1 var(--mono);
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .85);
  backdrop-filter: blur(6px);
}

.legend .swatches { display: flex; }
.legend .sw { width: 1.35rem; height: .5rem; }


.readout {
  position: absolute; right: .9rem; top: .9rem;
  min-width: 12rem;
  padding: .7rem .8rem;
  background: rgba(0, 0, 0, .62);
  border: 1px solid rgba(255, 255, 255, .16);
  color: rgba(255, 255, 255, .85);
  backdrop-filter: blur(6px);
}
.readout[hidden] { display: none; }

.readout-title {
  margin: 0 0 .35rem;
  font: 600 var(--step--1)/1 var(--display);
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.readout dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .18rem .6rem; }
.readout dt { color: var(--muted); font-size: var(--step--1); }
.readout dd {
  margin: 0; text-align: right;
  font: 500 var(--step--1)/1.4 var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ rail */

.rail { display: flex; flex-direction: column; gap: 1rem; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }

.tile {
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  padding: .8rem .8rem .9rem 0;
}

.tile .k {
  margin: 0 0 .15rem;
  font: 500 var(--step--1)/1 var(--sans);
  color: var(--muted);
  letter-spacing: .02em;
}

.tile .v {
  margin: 0;
  font: 600 var(--step-2)/1.05 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.tile .u { font-size: var(--step--1); color: var(--muted); margin-left: .2rem; }
.tile.is-flag .v { color: var(--flag); }
.tile.is-accent .v { color: var(--accent); }

/* A rule and a column, not a card. Every panel in the studio's system is
   separated by a hairline and its own whitespace. */
.panel {
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  padding: 1.1rem 0 0;
}

.panel h2 {
  margin: 0 0 .2rem;
  font: 600 var(--step-0)/1.2 var(--display);
  letter-spacing: .02em;
}

.panel-note, .caveat {
  margin: 0 0 .6rem;
  color: var(--muted);
  font-size: var(--step--1);
  line-height: 1.45;
}

.caveat { margin: .6rem 0 0; }
.caveat strong { color: var(--flag); font-weight: 600; }

.chart { display: block; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { transition: opacity .15s; }
.chart .bar:hover { opacity: .75; }
.chart .axis { fill: var(--muted); font: 400 .62rem/1 var(--mono); }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }

.bars { display: flex; flex-direction: column; gap: .45rem; }

.measure { display: grid; grid-template-columns: 1fr auto; gap: .2rem .5rem; align-items: center; }
.measure .label { font-size: var(--step--1); color: var(--ink-2); }
.measure .n {
  font: 500 var(--step--1)/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.measure .track {
  grid-column: 1 / -1;
  height: .4rem;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.measure .fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width .9s cubic-bezier(.2, .7, .2, 1);
}

/* ------------------------------------------------------------------ foot */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem 1.25rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font: 400 var(--step--1)/1.4 var(--mono);
  flex-wrap: wrap;
}

body.dragging .canvaswrap { outline: 2px dashed var(--accent); outline-offset: -6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ------------------------------------------------------------- findings */

/* The analysis ranks its findings so a refusal leads. The styling has to carry
   that: a blocked finding must not look like a pleasant statistic sitting one
   card above it. */
.insights h2 { margin-bottom: .35rem; }

.finding {
  border-left: 3px solid var(--line);
  padding: .55rem 0 .55rem .7rem;
  margin-top: .7rem;
}

.finding .sev {
  font: 500 .66rem/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .3rem;
}

.finding h3 {
  font-size: var(--step-0);
  font-weight: 600;
  margin: 0 0 .25rem;
  line-height: 1.3;
}

.finding .detail { margin: 0; color: var(--ink-2); line-height: 1.5; font-size: .88rem; }

/* The way out of a refusal. Given the accent rather than the muted grey a basis
   gets, because this is the actionable line on the card. */
.finding .remedy {
  margin: .45rem 0 0;
  color: var(--ink-2);
  font-size: .82rem;
  line-height: 1.5;
}

.finding .remedy span {
  display: inline-block;
  font: 500 .64rem/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: .35rem;
}

/* Whose threshold this is being judged against. Set apart, because the
   distinction between a measurement and a rule of thumb is the point. */
.finding .basis {
  margin: .4rem 0 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.45;
  border-top: 1px dotted var(--line);
  padding-top: .35rem;
}

.finding.is-blocked { border-left-color: var(--flag); }
.finding.is-blocked .sev { color: var(--flag); }
.finding.is-caution { border-left-color: var(--ramp-2); }
.finding.is-caution .sev { color: var(--ramp-2); }
.finding.is-notable { border-left-color: var(--accent); }
.finding.is-context { border-left-color: var(--line); }

/* ------------------------------------------------------------ brushing */

.hist { touch-action: none; cursor: crosshair; }
.hist .brush { fill: var(--accent); opacity: .13; }

.filterbar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  padding: .4rem 0 .1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font: 500 .78rem/1 var(--mono);
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  padding: .3rem .4rem .3rem .55rem;
}

.chip button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0 .15rem;
}

.chip-note { font: 400 .78rem/1 var(--mono); color: var(--muted); }

.readout-title .pin {
  font: 500 .62rem/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-left: .35rem;
}


/* --------------------------------------------------- measure distributions */

/* All six measures in one panel. The one the plan is coloured by is open; the
   rest are a short row and a squat chart, because six full panels made the rail
   three times the height of the plan beside it. */
.measure-chart { border-top: 1px solid var(--line-soft); padding-top: .5rem; margin-top: .5rem; }
.measure-chart:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }

.measure-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
  border: 0;
  background: none;
  padding: 0 0 .2rem;
  cursor: pointer;
  color: var(--muted);
  font: 500 var(--step--1)/1.3 var(--sans);
  text-align: left;
}

.measure-head:hover { color: var(--accent); }
.measure-head .n { font: 400 .68rem/1 var(--mono); color: var(--muted); }

.measure-chart.is-active .measure-head { color: var(--ink); font-weight: 600; }
.measure-chart.is-active .measure-head .n { color: var(--accent); }

/* Collapsed charts keep their shape but give up the height. */
.measure-chart .chart svg { height: 44px; }
.measure-chart.is-active .chart svg { height: auto; }

/* Plain description folds away; refusals and things worth acting on do not. */
.insights .more { margin-top: .8rem; }

.insights .more > summary {
  cursor: pointer;
  color: var(--muted);
  font: 500 var(--step--1)/1.4 var(--sans);
  padding: .35rem 0;
  border-top: 1px solid var(--line-soft);
}

.insights .more > summary:hover { color: var(--accent); }
.insights .more[open] > summary { color: var(--ink); }
