/*
 * The scenario funnel's rungs (ticket 009), drawn as one card per Status Service on Reports ›
 * Effectiveness (ticket 983, js/views/effectiveness.js) and as the technique page's funnel
 * (js/views/entities.js). The `.deception-rung*` rules are shared by both; the cards and their grid
 * are Effectiveness's own. Bars are a neutral ink, not the accent (design note rule 3: the accent marks
 * only interactive things).
 */

.effectiveness-funnels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: start;
  gap: var(--space-4);
}

.effectiveness-funnel {
  padding: var(--space-4) var(--space-4) var(--space-5);
  background: linear-gradient(135deg, var(--card-from), var(--card-to));
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.effectiveness-funnel__title {
  margin: 0;
  font: var(--type-headline);
  color: var(--ink);
}

.effectiveness-funnel__meta {
  margin: var(--space-1) 0 var(--space-4);
  color: var(--ink-muted);
  font: var(--type-footnote);
}

.deception-rungs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* The vertical connector between rungs — a short line above every rung except the first, drawn as
   a pseudo-element so no extra DOM node is needed per gap. */
.deception-rung {
  position: relative;
  padding-top: 0.65rem;
}

.deception-rung:first-child {
  padding-top: 0;
}

.deception-rung:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0.6rem;
  width: 1px;
  height: 0.65rem;
  background: var(--border);
}

.deception-rung__row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.deception-rung__label {
  flex: 1 1 auto;
  color: var(--ink-body);
  font-size: var(--fs-sm);
}

.deception-rung__count {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.deception-rung__pct {
  min-width: 3.5rem;
  text-align: right;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
}

.deception-rung__track {
  margin-top: 0.3rem;
  height: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
}

.deception-rung__bar {
  height: 100%;
  min-width: 2px;
  background: var(--ink-dim);
  border-radius: 999px;
}

/*
 * Meeting Sites and Legend (ticket 001086, audit pages 29 and 30). The card styles of both pages live in
 * console.css and decoys-reports.css, which other tickets edit; what this ticket changes is set here, and
 * this sheet loads after both.
 */

/* A Meeting Site card: a column with one gap between its rows, the actions at the foot. The count and its
   Partial chip had no gap ("2,459 requests Partial"). */
.service-card--inventory,
.service-card--observed {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.service-card--inventory .service-card__name,
.service-card--observed .service-card__name {
  margin: 0;
}

.service-card__count {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
}

.service-card__requests {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.service-card__actions {
  margin-top: auto;
}

/* "Details" was a bare disclosure triangle in body text. It is a bordered control with an accent arrow, so
   a reader sees there is something behind it. */
.service-card__details > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.25rem 0.7rem 0.25rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.45rem;
  color: var(--ink);
  font-size: var(--fs-xs);
  cursor: pointer;
  list-style: none;
}

.service-card__details > summary::-webkit-details-marker {
  display: none;
}

.service-card__details > summary::before {
  content: "▸";
  color: var(--gold);
  font-size: var(--fs-sm);
}

.service-card__details[open] > summary::before {
  content: "▾";
}

.service-card__details > summary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.service-card__details > summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.service-card__details > .service-card__facts {
  margin: var(--space-3) 0 0;
}

.service-next-step {
  margin: var(--space-5) 0 0;
}

/* The Legend gallery: a card is as tall as its own words. Rows used to stretch every card to the tallest in
   its row, which left 100 px of empty body above "Runs:" in a short card. */
.scenario-gallery {
  align-items: start;
}

.scenario-card[hidden],
.scenario-gallery__filter-row[hidden] {
  display: none;
}

.scenario-gallery__filter-row {
  margin-bottom: var(--space-3);
}

.scenario-gallery__filter {
  box-sizing: border-box;
  width: 100%;
  max-width: 28rem;
}

.scenario-slot-control__hint {
  margin: var(--space-2) 0 0;
}

/* Rapid prototype (legend dissolve): "Add a Meeting Site" under the Meeting Sites cards. */
.site-catalog {
  margin-top: 1.5rem;
}
.site-catalog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-catalog__head .section__hint {
  margin: 0.25rem 0 0;
}
.site-catalog__body {
  margin-top: 0.9rem;
}
.site-catalog__body[hidden],
.site-catalog[hidden] {
  display: none;
}
.site-catalog__error,
.service-card__remove-error {
  color: var(--danger, #e5484d);
  font-size: 0.85rem;
  margin: 0.4rem 0 0;
}
.site-catalog__error[hidden] {
  display: none;
}
.service-card__remove {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.site-catalog__advanced {
  margin-top: 0.75rem;
}
.company-settings {
  margin-top: 0.5rem;
}

/* Rapid prototype (legend dissolve): Company profiles. */
.company-profiles__grid {
  margin-top: 0.9rem;
}
.company-profile-editor {
  margin: 0.9rem 0;
  padding: 1rem 1.25rem;
  display: grid;
  gap: 0.6rem;
}
.company-profile-editor__actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.4rem;
}
.company-profile-editor__rule {
  border: 1px solid var(--border, rgba(127, 127, 127, 0.25));
  border-radius: 10px;
  padding: 0.6rem 0.8rem 0.8rem;
  margin: 0.3rem 0 0;
  min-width: 0;
}
.company-profile-editor__rule-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.company-station__rule,
.company-station__apply {
  margin-top: 0.3rem;
}
.company-station__apply[data-apply="error"] {
  color: var(--danger, #c0392b);
}
.company-stations {
  margin-top: 1.5rem;
}
.company-stations__table td {
  vertical-align: middle;
}
.company-station__select {
  min-width: 12rem;
}
.company-station__custom {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.company-profiles__status:empty {
  display: none;
}
.company-home__head {
  margin-top: 2rem;
}

/* Custom site templates: "Your templates" above the bundled cards (views/scenario.js) and the editor of
   one template (views/site_template.js). The cards reuse .scenario-card; only what is new is here. */
.scenario-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: var(--space-5) 0 var(--space-3);
}

.scenario-group-head:first-of-type {
  margin-top: 0;
}

.scenario-group-title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}

.scenario-own__empty {
  grid-column: 1 / -1;
  margin: 0;
}

.scenario-card__pick--link {
  text-decoration: none;
}

.scenario-card__pick--link:hover {
  text-decoration: underline;
}

.scenario-card__byline {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
}

.scenario-card--own .scenario-card__actions {
  flex-wrap: wrap;
  align-items: center;
}

.scenario-card__ask {
  flex-basis: 100%;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  color: var(--ink-body);
}

.template-editor > .section:first-of-type {
  margin-top: var(--space-4);
}

.template-meta {
  margin: 0;
}

.template-use {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--panel);
}

.template-use__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
}

.template-use__text {
  flex: 1 1 16rem;
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink-body);
}

.template-use__text.is-current {
  color: var(--health-ok);
}

.template-use__slot {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-xs);
  color: var(--ink-dim);
}

.template-use .section__hint {
  display: block;
  margin: var(--space-2) 0 0;
}

.template-pages:empty {
  display: none;
}

.template-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.template-more__ask {
  font-size: var(--fs-xs);
  color: var(--ink-body);
}

/* The page editor of a custom site template (views/site_template_pages.js): the template's Meeting Sites
   as a row of tabs, the chosen site's pages as a numbered list, and one small form. */
.template-sites {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.template-site-tab {
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.6rem;
  background: var(--panel);
  color: var(--ink-dim);
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  cursor: pointer;
}

.template-site-tab strong {
  color: var(--ink-body);
  font-weight: 600;
}

.template-site-tab.is-selected {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.template-site-tab.is-selected strong {
  color: var(--gold);
}

.template-site-tab:disabled {
  cursor: default;
  opacity: 0.6;
}

.template-site-tab:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.template-pages__locked {
  display: block;
  margin: var(--space-3) 0 0;
  color: var(--st-4xx);
}

.template-site-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) 0 0;
}

.template-pages__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: var(--space-5) 0 var(--space-2);
}

.template-pages__head .section__hint {
  margin: 0;
}

.template-rows {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--panel);
}

.template-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
}

.template-row:first-child {
  border-top: 0;
}

.template-row--open {
  display: block;
  padding: var(--space-2);
}

.template-row__number {
  padding-top: 0.1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
  text-align: right;
}

.template-row__line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
}

.template-row__address {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.template-row__methods {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
}

.template-row__answer {
  margin: 0.2rem 0 0;
  font-size: var(--fs-xs);
  color: var(--ink-body);
  overflow-wrap: anywhere;
}

.template-row--advanced .template-row__answer {
  color: var(--ink-dim);
}

.template-row__note {
  margin: 0.3rem 0 0;
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
  overflow-wrap: anywhere;
}

.template-row__note--warn {
  color: var(--st-4xx);
}

.template-row__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
}

.template-row__ask {
  margin-right: var(--space-1);
  font-size: var(--fs-2xs);
  color: var(--ink-body);
}

.template-notfound {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  font-size: var(--fs-xs);
  color: var(--ink-body);
}

.template-notfound__label {
  color: var(--ink-dim);
}

.template-form {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-3) 0;
  padding: var(--space-4);
  border: 1px solid var(--gold);
  border-radius: 0.7rem;
  background: var(--panel-deep);
}

.template-row--open .template-form {
  margin: 0;
}

.template-form__title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}

.template-form__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3) var(--space-4);
}

.template-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
}

.template-form__field--wide {
  flex: 1 1 100%;
}

.template-form__row > .template-form__field--wide:first-child {
  flex: 1 1 18rem;
}

.template-form__label {
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
}

.template-form__hint {
  max-width: 34rem;
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
}

.template-form__hint--warn {
  color: var(--st-4xx);
}

.template-form__hint:empty {
  display: none;
}

.template-form__short {
  width: 7rem;
}

.template-form__text {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  line-height: 1.45;
}

.template-form__text--mono {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.template-form__checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.template-form__check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--ink-body);
}

.template-form details > summary {
  cursor: pointer;
  color: var(--ink-dim);
}

.template-form details[open] > summary {
  margin-bottom: 0.3rem;
}

.template-form__problems {
  margin: 0;
  padding-left: 1.1rem;
}

.template-form__actions {
  display: flex;
  gap: var(--space-2);
}

.template-form .scenario-alert {
  margin-top: 0;
}

/* "Raise an alert when this page is touched": the one switch of the page form, set off in a box of its
   own that lights up while it is on. */
.template-form__alert {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: 0.6rem;
  background: var(--panel);
}

.template-form__alert.is-on {
  border-color: var(--st-5xx);
}

.template-form__switch {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
}

.template-form__switch input {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.15rem 0 0;
  accent-color: var(--st-5xx);
}

.template-form__switch-text {
  display: grid;
  gap: 0.2rem;
}

.template-form__switch-text strong {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
}

/* A page that raises an alert says so in the list, under what it answers. */
.template-row__alert {
  margin: 0.35rem 0 0;
  font-size: var(--fs-2xs);
  color: var(--ink-body);
  overflow-wrap: anywhere;
}

.template-row__alert-mark {
  display: inline-block;
  margin-right: 0.15rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--st-5xx);
  border-radius: 0.35rem;
  background: var(--st-5xx);
  color: #fff;
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* The same colours the Fleet page gives a high and a medium alert. */
.template-row__alert--medium .template-row__alert-mark {
  border-color: var(--st-4xx);
  background: var(--st-4xx);
  color: #111;
}

.template-row:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

/* "Leave without saving?": stays in sight wherever the Chief is on the page. */
.template-leave {
  position: sticky;
  top: var(--space-2);
  z-index: 5;
}

.template-leave:empty {
  display: none;
}

.template-leave .scenario-alert {
  margin: 0 0 var(--space-3);
  background: var(--panel-deep);
}

.template-rename {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}

.template-rename .template-form__field--wide {
  flex: 1 1 20rem;
}

.template-rename .scenario-alert {
  flex-basis: 100%;
}

.template-yaml > summary {
  cursor: pointer;
  font: var(--type-title);
}

.template-yaml > .scenario-lede {
  margin-top: var(--space-2);
}

.template-pages__files {
  display: block;
  margin: var(--space-2) 0 0;
}

/* A button that cannot be pressed now (a form is open, a save is in flight) reads as such. */
.template-editor .btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* The remote Stations that run a template, in its editor's use box. */
.template-use__stations {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink-body);
}

/* Under the Home Station's own line, set off by a rule. */
.template-use__stations--after {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.template-use > .template-use__how:first-child {
  margin-top: 0;
}

.template-use__results {
  margin: var(--space-2) 0 0;
  padding-left: 1.1rem;
  font-size: var(--fs-xs);
  color: var(--ink-body);
}

.template-use__results .is-ok strong {
  color: var(--health-ok);
}

.template-use__results .is-refused strong {
  color: var(--st-4xx);
}

.template-use__confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
