/*
 * triangulation.css
 * The chart owns the page. Everything around it stays quiet.
 */

:root {
  --paper: #f7f0da;
  --paper-lit: #fffdf3;
  --ink: #2f2c22;
  --ink-soft: #6f6a58;
  --rule: #ded5b9;
  --designer: #8dc63f;
  --client: #00b3f0;
  --user: #f15a29;
  --sans: Futura, "Avenir Next", "Century Gothic", "Trebuchet MS", "Segoe UI", sans-serif;
  --stage-min: 800px;
  --stage-max: 1920px;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-width: var(--stage-min);
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Masthead ---------------------------------------------------------------- */

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 3rem;
  width: min(100%, var(--stage-max));
  margin: 0 auto;
  padding: 2rem 2.5rem 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.masthead h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0.38em;
  text-transform: uppercase;
}

.masthead__title p {
  margin: 0;
}

.masthead__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status {
  margin: 0 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  opacity: 0.55;
  transition: opacity 220ms ease;
}
.status.is-fresh { opacity: 1; color: var(--ink); }

.button {
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.95rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.button:hover { border-color: #b9b096; background: rgba(255, 253, 243, 0.7); }
.button--primary { border-color: var(--ink); }
.button:focus-visible { outline: 2px solid var(--client); outline-offset: 2px; }

/* Stage ------------------------------------------------------------------- */

.stage {
  width: min(100%, var(--stage-max));
  margin: 0 auto;
  padding: 1rem 2.5rem 0;
}

/* Layout sizing for the SVG lives here, not in the exportable chart style. */
.chart { display: block; width: 100%; height: auto; }

.stage__inner {
  width: min(100%, calc(100vh - 190px));
  min-width: var(--stage-min);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

/* Readout ----------------------------------------------------------------- */

.readout {
  width: min(100%, var(--stage-max));
  margin: 0 auto;
  padding: 0.75rem 2.5rem 1.25rem;
}

.readout__hint {
  letter-spacing: 0.14em;
  text-transform: none;
  opacity: 0.7;
}

.readout__heading {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.readout__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.readout__item {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.84rem;
  background: rgba(255, 253, 243, 0.78);
  border-left: 3px solid var(--rule);
}
.readout__item[data-class="core"] { border-left-color: #2f2c22; }
.readout__item[data-class="pair"] { border-left-color: #8a8264; }
.readout__item[data-class="single"] { border-left-color: #cfc7ad; }
.readout__share { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.readout__empty { margin: 0; font-size: 0.86rem; color: var(--ink-soft); }

/* Rollover guidance ------------------------------------------------------- */

.readout__item { cursor: help; }
.readout__item:hover,
.readout__item:focus-visible {
  background: var(--paper-lit);
  outline: none;
  box-shadow: 0 1px 0 var(--rule);
}

.guidance {
  /* One line, sitting clear of the percentages above and the sliders below. */
  margin: 20px 0 22px;
  padding: 0.7rem 0.95rem;
  min-height: 1.5em;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper-lit);
  border: 1px solid var(--rule);
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 120ms ease;
}
.guidance[data-state="rest"] { color: var(--ink-soft); font-style: italic; }

/* Below the width where a full recommendation fits on one line, let it wrap
   rather than truncate. Losing the end of a sentence is worse than two lines. */
@media (max-width: 1500px) {
  .guidance { white-space: normal; }
}

/* Control panel ----------------------------------------------------------- */

.panel {
  width: min(100%, var(--stage-max));
  margin: 0 auto;
  padding: 0 2.5rem 2.5rem;
}

.panel__columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  align-items: start;
}

.domain {
  border-top: 2px solid var(--field, var(--rule));
  padding-top: 0.9rem;
}
.domain[data-domain="designer"] { --field: var(--designer); }
.domain[data-domain="client"] { --field: var(--client); }
.domain[data-domain="user"]   { --field: var(--user); }

.domain__head {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.domain__swatch {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--field);
  transform: translateY(1px);
}

.domain__name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.domain__reset {
  font: inherit;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.16rem 0.5rem;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}
.domain__reset:hover { color: var(--ink); border-color: #b9b096; }
.domain__reset:focus-visible { outline: 2px solid var(--client); outline-offset: 2px; }

.domain__count {
  margin: 0 0 0 auto;
  font-size: 0.75rem;
  color: var(--ink-soft);
}
.domain__count.is-short { color: #a8562c; }

.domain__slots { display: grid; gap: 0.55rem; }

.slot {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem 0.8rem;
  background: rgba(255, 253, 243, 0.66);
  border: 1px solid var(--rule);
  border-radius: 2px;
  transition: opacity 140ms ease;
}
.slot--off { opacity: 0.5; }
.slot--off:focus-within { opacity: 1; }

.slot__top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.slot__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.slot__toggle input { margin: 0; accent-color: var(--dot); }

.slot__dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--dot);
}

.slot__seat { letter-spacing: 0.04em; }

.slot__axis {
  font: inherit;
  font-size: 0.78rem;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.28rem 0.3rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  cursor: pointer;
}
.slot__axis:focus-visible { outline: 2px solid var(--client); outline-offset: 1px; }

.slot__scale {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 2.4fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.slot__pole {
  font-size: 0.62rem;
  letter-spacing: 0.13em;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot__pole--b { text-align: right; }

.slot__range {
  width: 100%;
  margin: 0;
  accent-color: var(--dot);
  cursor: ew-resize;
}
.slot__range:focus-visible { outline: 2px solid var(--client); outline-offset: 3px; }

.slot__readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.slot__value {
  font-size: 0.78rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.slot__number {
  font: inherit;
  font-size: 0.78rem;
  width: 5.2rem;
  padding: 0.22rem 0.35rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

/* Colophon ---------------------------------------------------------------- */

.colophon {
  width: min(100%, var(--stage-max));
  margin: 0 auto;
  padding: 1.25rem 2.5rem 3rem;
  border-top: 1px solid var(--rule);
}
.colophon {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 3rem;
}
.colophon p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.colophon__note { max-width: 74ch; }
.colophon__rights {
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
}


/* Narrow screens ---------------------------------------------------------- */

/*
 * The eight hundred pixel floor holds on any screen wide enough to honour it.
 * Below that the floor becomes the problem it was meant to prevent: a page
 * that cannot be read without dragging it sideways. These rules release the
 * floor rather than adding a second page to maintain, so there is one set of
 * markup and one set of behaviour to keep correct.
 *
 * The slider stacks are the part that genuinely changes. Three columns become
 * one, each row gains vertical room, and the controls grow to a thumb sized
 * target instead of a pointer sized one.
 */

@media (max-width: 1080px) {
  .panel__columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  :root { --stage-min: 0px; }

  body { min-width: 0; }

  .masthead,
  .stage,
  .readout,
  .panel,
  .colophon {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .masthead {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .masthead h1 { font-size: 1.15rem; letter-spacing: 0.26em; }
  .masthead__title p { font-size: 0.88rem; }
  .masthead__actions { justify-content: flex-start; }

  /* Square and full bleed, so the chart keeps as much of the screen as the
     viewport will give it without forcing a sideways drag. */
  .stage { padding-top: 0.5rem; }
  .stage__inner {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .readout__heading { font-size: 0.66rem; letter-spacing: 0.22em; }
  .readout__hint { display: block; margin-top: 0.3rem; letter-spacing: 0.08em; }

  /* Touch has no hover, so the line responds to a tap on a chip instead. */
  .readout__item { padding: 0.5rem 0.75rem; font-size: 0.9rem; }
  .guidance { white-space: normal; margin: 16px 0 18px; }

  .panel__columns { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; }

  .domain__head { flex-wrap: wrap; row-gap: 0.4rem; }
  .domain__count { margin-left: 0; flex-basis: 100%; }

  .slot { padding: 0.85rem 0.9rem; gap: 0.6rem; }
  .slot__top { flex-wrap: wrap; row-gap: 0.45rem; }
  .slot__axis { flex-basis: 100%; font-size: 0.86rem; padding: 0.5rem 0.3rem; }

  /* Poles above, slider below. Side by side leaves the slider too short to
     place a value accurately with a thumb. */
  .slot__scale { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: 0.15rem; }
  .slot__pole { grid-row: 1; font-size: 0.66rem; }
  .slot__pole--a { grid-column: 1; }
  .slot__pole--b { grid-column: 2; }
  .slot__range { grid-row: 2; grid-column: 1 / -1; height: 2rem; }

  .slot__value { font-size: 0.86rem; }
  .slot__number { font-size: 0.95rem; width: 5.5rem; padding: 0.45rem 0.5rem; }

  .domain__reset { padding: 0.35rem 0.7rem; font-size: 0.7rem; }
  .button { padding: 0.6rem 0.9rem; }

  .colophon { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .colophon__rights { text-align: left; white-space: normal; }
}

/* Coarse pointers get real targets regardless of viewport width. */
@media (pointer: coarse) {
  .slot__range { height: 2.25rem; }
  .slot__toggle input { width: 1.15rem; height: 1.15rem; }
  .readout__item { cursor: default; }
}

/* Account control ---------------------------------------------------------- */

.account { position: relative; display: inline-flex; align-items: center; gap: 0.5rem; }

.account__who {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.account__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: 19rem;
  display: grid;
  gap: 0.6rem;
  padding: 1rem;
  background: var(--paper-lit);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(47, 44, 34, 0.16);
  text-align: left;
}
.account__panel[hidden] { display: none; }

.account__tabs { display: flex; gap: 0.25rem; margin-bottom: 0.2rem; }

.account__tab {
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex: 1 1 auto;
  padding: 0.4rem 0.3rem;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--rule);
  cursor: pointer;
}
.account__tab.is-on { color: var(--ink); border-bottom-color: var(--ink); }

.account__field { display: grid; gap: 0.22rem; }
.account__field[hidden] { display: none; }

.account__field span {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.account__field input {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.5rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.account__field input:focus-visible { outline: 2px solid var(--client); outline-offset: 1px; }

.account__note {
  margin: 0;
  min-height: 1em;
  font-size: 0.76rem;
  line-height: 1.4;
  color: #a8562c;
}

.account__submit { width: 100%; }

@media (max-width: 860px) {
  .account { width: 100%; }
  .account__panel { right: auto; left: 0; width: min(100%, 22rem); }
}

/* Written reading state ---------------------------------------------------- */

.readout__state {
  display: inline-block;
  margin-left: 0.75rem;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 200ms ease;
}
.readout__state[data-state="waiting"],
.readout__state[data-state="working"] { opacity: 0.75; font-style: italic; }
.readout__state[data-state="ready"]   { opacity: 0.55; }
.readout__state[data-state="failed"]  { opacity: 0.5; }
.readout__state[data-state="spent"]   { opacity: 0.6; }

/* A written reading runs longer than the fixed guidance, so the line is
   allowed to wrap even on wide screens rather than being truncated. */
.guidance[data-state="reading"] {
  white-space: normal;
  color: var(--ink);
}


/* About / framing panel ---------------------------------------------------- */

.about {
  margin: 0.5rem 0 0;
  max-width: 64ch;
}

.about__lead {
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}

.about__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.4rem;
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  vertical-align: middle;
  transition: color 140ms ease;
}
.about__toggle:hover { color: var(--ink); }
.about__toggle:focus-visible { outline: 2px solid var(--client); outline-offset: 2px; border-radius: 2px; }

.about__arrow {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 220ms ease;
}
.about__toggle[aria-expanded="true"] .about__arrow {
  transform: rotate(-135deg) translateY(-2px);
}
.about__toggle-label {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.about__panel {
  margin-top: 1.4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem 3rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.4rem;
}
.about__panel[hidden] { display: none; }

.about__framing p,
.about__directions p {
  margin: 0 0 0.9em;
  font-size: 0.88rem;
  line-height: 1.62;
  color: var(--ink);
}
.about__framing p:last-child,
.about__directions p:last-child { margin-bottom: 0; }

.about__directions-heading {
  margin: 0 0 0.8em;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

@media (max-width: 860px) {
  .about__panel { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .masthead { padding-bottom: 1rem; }
}

/* Party labels (CLIENT / DESIGNER / USER) and region labels (ONE FIELD etc.) */

.about__party {
  padding-left: 0;
}

.about__party-label {
  display: inline;
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  /* color is set inline per domain */
}

.about__region-label {
  display: inline;
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
}

/* Section headings within the directions column use the same grey as the
   "How to read the regions" heading above them. */
.about__region-label--section {
  color: var(--ink-soft);
  letter-spacing: 0.28em;
}
