/* ---------- Figure kit: the figure editor of an editorial kit ----------
   Three columns in a full window: the view's figures as a list, the plate of
   the chosen one, and its settings. The editor fills what the window has, so
   a drawing is scaled to the room the middle column leaves and each column
   scrolls on its own, so the header and tabs stay where they are. Below the full stage the columns stack and the page
   scrolls. */

.pitch-site--app .figure-kit {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: 15rem minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-block-size: 0;
}

.pitch-site--app .figure-kit__list {
  border-inline-end: 1px solid rgb(14 17 17 / 0.14);
  display: flex;
  flex-direction: column;
  gap: var(--space-l);
  min-block-size: 0;
  overflow-y: auto;
  padding: 16px 12px;
}

.pitch-site--app .figure-kit__figures {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pitch-site--app .figure-kit__label {
  color: var(--ps-ink-soft);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.pitch-site--app .figure-kit__figures .figure-kit__label {
  padding: 0 8px 6px;
}

.pitch-site--app .figure-kit__item {
  border-radius: 6px;
  color: var(--ps-ink);
  font-size: 0.875rem;
  padding: 8px;
  text-decoration: none;
}

.pitch-site--app .figure-kit__item:hover {
  background: var(--ps-paper-deep);
}

.pitch-site--app .figure-kit__item.is-active {
  background: var(--ps-yellow);
  font-weight: 600;
}

.pitch-site--app .figure-kit__note {
  border-block-start: 1px solid rgb(14 17 17 / 0.14);
  color: var(--ps-ink-soft);
  padding: 12px 8px 0;
}

/* A view with nothing to draw says so in the editor's place, at its own
   height, rather than stretched down the column like a plate. */
.pitch-site--app .figure-kit > .stage-state {
  align-self: start;
  margin: 18px 22px;
}

.pitch-site--app .figure-kit__editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(20rem, 22vw, 26rem);
  grid-template-rows: minmax(0, 1fr);
  min-block-size: 0;
}

/* The plate column. A drawing carries its own paper, so it is framed in ink
   the way the file's edge will be; a table sits on the column's paper. */
.pitch-site--app .figure-kit__plate {
  background: var(--ps-paper-raised);
  gap: 10px;
  min-block-size: 0;
  padding: 18px 22px;
}

@media (min-width: 75rem) and (min-height: 45rem) {
  .pitch-site--app .figure-kit__plate {
    overflow-y: auto;
  }

  .pitch-site--app .figure-kit__plate.editorial-figure--grow .editorial-figure__body {
    flex: none;
  }
}

.pitch-site--app .figure-kit__plate .editorial-figure__body {
  place-items: center;
}

.pitch-site--app .figure-kit__plate .editorial-figure__body .figure-plate {
  border: 2px solid var(--ps-ink);
  box-sizing: border-box;
  max-inline-size: 100%;
}

.pitch-site--app .figure-kit__plate .editorial-figure__body[aria-busy="true"],
.pitch-site--app .figure-kit__file[aria-busy="true"] {
  opacity: 0.5;
}

.pitch-site--app .figure-kit__explanation {
  color: var(--ps-ink-soft);
  flex: none;
  max-inline-size: 70ch;
}

.pitch-site--app .figure-kit__controls {
  border-inline-start: 2px solid var(--ps-ink);
  display: flex;
  flex-direction: column;
  font-size: 0.875rem;
  gap: 14px;
  min-block-size: 0;
  overflow-y: auto;
  padding: 16px;
}

.pitch-site--app .figure-kit__section,
.pitch-site--app .figure-kit__form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pitch-site--app .figure-kit__form {
  gap: 14px;
}

.pitch-site--app .figure-kit__teams {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* The teams a figure is about, named with the colour each is drawn in. */
.pitch-site--app .figure-kit__team {
  align-items: center;
  color: var(--ps-ink);
  display: inline-flex;
  gap: 6px;
}

.pitch-site--app .figure-kit__team::before {
  background: var(--team-dot);
  border-radius: 50%;
  block-size: 10px;
  content: "";
  inline-size: 10px;
}

.pitch-site--app .figure-kit__team--home {
  --team-dot: var(--ps-turf);
}

.pitch-site--app .figure-kit__team--away {
  --team-dot: var(--ps-ink-soft);
}

/* The figure's own choices keep the chips and selects they have on a figure
   that wears them above its plot; here the panel rules them off instead. */
.pitch-site--app .figure-kit__controls .figure-kit__options {
  border-block-end: 0;
  padding-block-end: 0;
}

.pitch-site--app .figure-kit__controls .figure-kit__options .searchable-select,
.pitch-site--app .figure-kit__controls .figure-kit__options select {
  inline-size: 100%;
  max-inline-size: 100%;
}

.pitch-site--app .figure-kit__form input[type="text"],
.pitch-site--app .figure-kit__form textarea,
.pitch-site--app .figure-kit__form select,
.pitch-site--app .figure-kit__options select,
.pitch-site--app .figure-kit__options .searchable-select__input {
  background: var(--ps-paper-raised);
  border: 2px solid var(--ps-ink);
  border-radius: 8px;
  box-sizing: border-box;
  min-block-size: 2.5rem;
  padding: 8px 10px;
}

.pitch-site--app .figure-kit__form select,
.pitch-site--app .figure-kit__options select,
.pitch-site--app .figure-kit__options .searchable-select__input {
  font-size: 0.875rem;
}

.pitch-site--app .figure-kit__form input[type="text"],
.pitch-site--app .figure-kit__form textarea {
  font-size: 1rem;
}

.pitch-site--app .figure-kit__form textarea {
  field-sizing: content;
  line-height: 1.45;
  max-block-size: 10lh;
  min-block-size: 4.5lh;
  resize: vertical;
}

/* The label row of a text field holds the label and one more thing: that the
   text is the data's suggestion, or, once it is edited, the way back to it. */
.pitch-site--app .figure-kit__field-head {
  min-block-size: 1.25rem;
}

.pitch-site--app .figure-kit__suggested,
.pitch-site--app .figure-kit__count {
  color: var(--ps-ink-soft);
  font-size: 0.75rem;
  margin: 0;
}

.pitch-site--app .figure-kit__count {
  font-variant-numeric: tabular-nums;
  text-align: end;
}

.pitch-site--app .figure-kit__reset {
  background: none;
  border: 0;
  color: var(--ps-ink-soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  padding: 0;
  text-decoration: underline;
}

.pitch-site--app .figure-kit__reset:hover {
  color: var(--ps-ink);
}

.pitch-site--app .figure-kit__controls .figure-export__ratios {
  gap: 4px;
}

.pitch-site--app .figure-kit__themes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pitch-site--app .figure-kit__theme {
  align-items: center;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  padding: 6px 8px;
}

.pitch-site--app .figure-kit__theme:has(input:checked) {
  background: color-mix(in oklab, var(--ps-sun, #e8b93b) 25%, transparent);
  border-color: var(--ps-ink);
}

.pitch-site--app .figure-kit__theme:has(input:focus-visible) {
  outline: var(--focus-ring-size) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.pitch-site--app .figure-kit__theme input {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.pitch-site--app .figure-kit__file {
  background: var(--ps-paper-raised);
  border: 1px solid rgb(14 17 17 / 0.14);
  min-block-size: 4rem;
}

.pitch-site--app .figure-kit__file svg {
  block-size: auto;
  display: block;
  inline-size: 100%;
  max-block-size: 18rem;
}

.pitch-site--app .figure-kit__ways-out {
  border-block-start: 1px solid rgb(14 17 17 / 0.14);
  gap: 8px;
  margin-block-start: auto;
  padding-block-start: 14px;
}

/* While the panel scrolls on its own, Save and the downloads stay at its
   foot, and a setting scrolled into view (by the keyboard or a click) is
   kept clear of them. The full window then holds still: the kit's columns
   are what scroll, never the header and tabs above them. */
@media (min-width: 75rem) and (min-height: 45rem) {
  .pitch-site--app .figure-kit__controls {
    scroll-padding-block-end: 15rem;
  }

  .pitch-site--app .figure-kit__ways-out {
    background: var(--ps-paper);
    inset-block-end: 0;
    margin: auto -16px -16px;
    padding: 12px 16px 16px;
    position: sticky;
  }

  .pitch-site--app .pitch-window--full .pitch-window__body:has(.figure-kit) {
    overflow: clip;
  }
}

.pitch-site--app .figure-kit__download-label {
  margin-block-start: 6px;
}

/* While Save stays in view, the subtitle grows only so far before it
   scrolls in its own box, so the settings under it are not pushed beneath
   the foot on a screen of ordinary height. */
@media (min-width: 75rem) and (min-height: 45rem) and (max-height: 64rem) {
  .pitch-site--app .figure-kit__form textarea {
    max-block-size: 4.5lh;
    min-block-size: 3lh;
  }

  .pitch-site--app .figure-kit__controls .figure-export__use {
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }

  .pitch-site--app .figure-kit__controls .figure-export__field:has(input[value="16:9"]:checked) .figure-export__use[data-ratio="16:9"],
  .pitch-site--app .figure-kit__controls .figure-export__field:has(input[value="4:3"]:checked) .figure-export__use[data-ratio="4:3"],
  .pitch-site--app .figure-kit__controls .figure-export__field:has(input[value="1:1"]:checked) .figure-export__use[data-ratio="1:1"],
  .pitch-site--app .figure-kit__controls .figure-export__field:has(input[value="4:5"]:checked) .figure-export__use[data-ratio="4:5"],
  .pitch-site--app .figure-kit__controls .figure-export__field:has(input[value="9:16"]:checked) .figure-export__use[data-ratio="9:16"] {
    display: -webkit-box;
  }
}

/* On a shorter screen the settings do not fit above a foot that stays in
   view, so the foot follows them instead of covering one, kept compact:
   one row each for Save, the pictures and the data. */
@media (min-width: 75rem) and (min-height: 45rem) and (max-height: 56rem) {
  .pitch-site--app .figure-kit__controls {
    scroll-padding-block-end: 0;
  }

  .pitch-site--app .figure-kit__ways-out {
    gap: 6px;
    padding-block: 8px 12px;
    position: static;
  }

  .pitch-site--app .figure-kit__ways-out .figure-kit__button {
    min-block-size: 0;
    padding-block: 6px;
  }

  .pitch-site--app .figure-kit__download-label {
    margin-block-start: 0;
  }
}

.pitch-site--app .figure-kit__saved a {
  color: var(--ps-ink);
}

.pitch-site--app .figure-kit__saved::before {
  background: var(--ps-turf);
  border-radius: 50%;
  block-size: 8px;
  content: "";
  display: inline-block;
  inline-size: 8px;
  margin-inline-end: 6px;
}

.pitch-site--app .figure-kit__button {
  justify-content: center;
  min-width: 0;
  text-align: center;
  width: 100%;
}

.pitch-site--app .figure-kit__save summary {
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  list-style: none;
}

.pitch-site--app .figure-kit__save summary::-webkit-details-marker {
  display: none;
}

.pitch-site--app .figure-kit__folders {
  background: var(--ps-paper-raised);
  border: 1px solid rgb(14 17 17 / 0.14);
  border-radius: 8px;
  display: block;
  margin-block-start: 10px;
  padding: 10px;
}

.pitch-site--app .figure-kit__files {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr;
}

.pitch-site--app .figure-kit__files--data {
  grid-template-columns: repeat(3, 1fr);
}

.pitch-site--app .figure-kit__files--data .btn {
  background: transparent;
  border-width: 1px;
  box-shadow: none;
  font-weight: 500;
  justify-content: center;
  min-block-size: 0;
  min-width: 0;
  padding-block: 4px;
}

.pitch-site--app .figure-kit__reading {
  color: var(--ps-ink-soft);
}

/* What kind of kit this is and how much it holds, at the end of the tab row. */
.pitch-site--app .figure-kit-count {
  color: var(--ps-cream-soft);
  font-size: 0.8125rem;
}

/* Story findings share the kit's full window, so the tabs above them stay as
   wide as they are over the editor; the full window pads nothing itself. */
.pitch-site--app .figure-kit-findings {
  display: block;
}

.pitch-site--app .figure-kit-findings > .container-large {
  padding-inline: clamp(16px, 3vw, 32px);
}

/* Narrower than the full stage the figure list folds into a row of chips
   above the editor, which keeps the plate and its settings side by side; only
   a narrow screen stacks them. */
@media (max-width: 74.999rem) {
  .pitch-site--app .figure-kit {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
  }

  .pitch-site--app .figure-kit__editor {
    grid-template-columns: minmax(0, 1fr) 20rem;
    grid-template-rows: none;
  }

  .pitch-site--app .figure-kit__list {
    border-block-end: 1px solid rgb(14 17 17 / 0.14);
    border-inline-end: 0;
    overflow-y: visible;
  }

  .pitch-site--app .figure-kit__figures {
    flex-flow: row wrap;
  }

  .pitch-site--app .figure-kit__figures .figure-kit__label {
    flex-basis: 100%;
  }

  .pitch-site--app .figure-kit__controls {
    overflow-y: visible;
  }
}

@media (max-width: 49.999rem) {
  .pitch-site--app .figure-kit__editor {
    grid-template-columns: minmax(0, 1fr);
  }

  .pitch-site--app .figure-kit__controls {
    border-block-start: 2px solid var(--ps-ink);
    border-inline-start: 0;
  }
}

/* A figure with nothing to set or save takes the whole width; its note sits under it. */
.pitch-site--app .figure-kit__editor--plain {
  grid-template-columns: minmax(0, 1fr);
}

.pitch-site--app .figure-kit__controls .squad-table-controls__groups {
  border: 0;
  margin: 0;
  padding: 0;
}

.pitch-site--app .figure-kit__controls .squad-table-controls__groups legend {
  padding: 0;
}
