/* Publishing a spec by hand: the page about publishing, where a person
   puts a spec together in the browser. Only that page loads this file. The
   colours, the type and the buttons are the site's own, from style.css. */

/* The start: a panel of sky to drop a folder on, and the draft the browser
   kept from last time. */
.byhand {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.draft-start {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  margin: 0 0 3rem;
}

.draft-dropzone {
  --in: calc(1.75rem + 2px);
  padding: 1.75rem;
  border: 2px dashed transparent;
  border-radius: 0.875rem;
  background: var(--sky);
}

.byhand.is-over .draft-dropzone {
  border-color: var(--ink);
}

.draft-dropzone h2 {
  margin-bottom: 0.5rem;
  font-size: 1.0625rem;
  letter-spacing: -0.005em;
  line-height: 1.4;
}

/* On a wide page the panel keeps to the sheet's four columns, as the
   sections under it do: its name on the first, what it says and its
   buttons on the two beside it. */
@media (min-width: 62.5rem) {
  .draft-dropzone {
    display: grid;
    grid-template-columns:
      calc((100% + 2 * var(--in) - 3 * var(--gap)) / 4 - var(--in))
      minmax(0, calc((100% + 2 * var(--in) - 3 * var(--gap)) / 2 + var(--gap)));
    gap: 0 var(--gap);
  }

  .draft-dropzone h2 {
    grid-column: 1;
    grid-row: 1 / span 4;
    margin: 0;
  }

  .draft-dropzone > :not(h2) {
    grid-column: 2;
  }
}

.draft-dropzone p {
  max-width: 36rem;
  margin: 0;
  color: var(--sky-mute);
}

.draft-choose {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-top: 1.25rem;
}

.draft-choose .button-quiet {
  border-color: var(--ink);
}

.draft-dropzone .hint {
  margin-top: 1rem;
  color: var(--sky-mute);
}

.draft-dropzone .hint:empty {
  display: none;
}

.draft-dropzone .hint a {
  color: var(--ink);
  font-weight: 600;
}

.draft-saved h3 {
  margin-bottom: 0.5rem;
}

.draft-saved-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.875rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.draft-saved-row p {
  margin: 0;
  color: var(--mute);
}

.draft-saved-row strong {
  color: var(--ink);
}

/* While a draft is open it is the page: the rest of the page about
   publishing waits behind the link back to it. */
main.is-drafting > section:not(#by-hand) {
  display: none;
}

main.is-drafting {
  gap: 0;
  padding-top: 0;
}

.draft {
  display: flex;
  flex-direction: column;
}

.draft-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.draft-small {
  min-height: 44px;
  padding: 0 0.875rem;
  border-width: 1px;
  border-color: var(--field);
  border-radius: 0.625rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.button.draft-small:not(.button-quiet) {
  border-color: var(--ink);
}

.draft-small.is-fail {
  color: var(--fail);
}

.draft-small.is-fail:hover {
  color: var(--bg);
}

.draft .button:disabled,
.draft-panel .button:disabled {
  opacity: 0.45;
  cursor: default;
}

.draft .button:disabled:hover {
  border-color: var(--ink);
  background: var(--ink);
}

.draft .button-quiet:disabled:hover {
  border-color: var(--field);
  background: transparent;
  color: var(--ink);
}

/* Something to press that reads as a link. */
.draft-link {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.draft-link:hover {
  color: var(--mute);
}

.draft-error {
  margin: 0.375rem 0 0;
  color: var(--fail);
  font-size: 0.92rem;
  font-weight: 600;
}

.draft-error:empty {
  display: none;
}

.draft-mono,
.field input.draft-mono {
  font-family: var(--mono);
  font-size: 0.92rem;
}

.draft-pill {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--pale);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

/* The bar over the draft: where this is, how many things are wrong, and
   Publish. */
.draft-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.draft-crumbs {
  margin: 0;
  font-size: 0.95rem;
}

.draft-crumbs .draft-link {
  color: var(--mute);
  font-weight: 400;
}

.draft-title {
  font-weight: 650;
}

.draft-acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.draft-count {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 600;
}

.draft-count.is-fail,
.draft-count.is-fail:hover {
  color: var(--fail);
}

.draft-acts .button {
  min-height: 44px;
  border-radius: 0.625rem;
}

/* The files on one side and the open file on the other. On a narrow
   screen the files come first. */
.draft-work {
  display: flex;
  align-items: stretch;
}

.draft-files {
  flex: 0 0 18.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  padding: 1rem 1rem 1.5rem 0;
  border-right: 1px solid var(--line);
}

.draft-side {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  padding: 1rem 0 2.5rem 1.5rem;
}

@media (max-width: 52rem) {
  .draft-work {
    flex-direction: column;
  }

  .draft-files {
    flex-basis: auto;
    padding-right: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .draft-side {
    padding-left: 0;
  }
}

.draft-files-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.draft-files-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.draft-files-acts {
  display: flex;
  gap: 0.375rem;
}

.draft-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.draft-tree .draft-tree {
  margin-top: 2px;
  padding-left: 1.375rem;
}

.draft-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  padding: 0 0.625rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.draft-item:hover {
  background: var(--pale);
}

.draft-item[aria-current="true"],
.draft-item[aria-current="true"]:hover {
  background: var(--ink);
  color: var(--bg);
}

.draft-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-item-note {
  margin-left: auto;
  padding-left: 0.5rem;
  font-family: var(--sans);
  font-size: 0.84rem;
  white-space: nowrap;
}

.draft-item.is-out .draft-item-name {
  text-decoration: line-through;
}

/* A folder: an arrow that points down while it is open. */
.draft-fold::before {
  content: "";
  flex: none;
  width: 0.45rem;
  height: 0.45rem;
  margin: 0 0.125rem 0.2rem 0.125rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.draft-fold[aria-expanded="false"]::before {
  margin-bottom: 0;
  transform: rotate(-45deg);
}

/* How many things are wrong with a file. */
.draft-mark {
  flex: none;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: var(--fail);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
}

.draft-total {
  margin: 0;
  font-size: 0.88rem;
}

.draft-drophint {
  margin: 0;
  padding: 0.75rem;
  border: 1px dashed var(--field);
  border-radius: 0.625rem;
  color: var(--mute);
  font-size: 0.88rem;
  line-height: 1.4;
}

.byhand.is-over .draft-drophint {
  border-color: var(--ink);
  color: var(--ink);
}

.draft-namer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
}

/* The open file. */
.draft-open {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.draft-file-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.draft-file-name {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.draft-file-head .hint {
  margin: 0.25rem 0 0;
}

.draft-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(17.5rem, 100%), 1fr));
  gap: 0.875rem 1.25rem;
  align-items: start;
}

.draft-facts > .hint {
  align-self: center;
  margin: 0;
}

.draft-out-note {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.draft-out-note p {
  margin: 0;
  color: var(--fail);
  font-size: 0.95rem;
  font-weight: 600;
}

.draft-picture {
  display: block;
  max-width: 100%;
  max-height: 32rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--pale);
}

.draft-about {
  margin: 0;
  padding: 0.25rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
}

.draft-about > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 1.125rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.draft-about > div:last-child {
  border-bottom: 0;
}

.draft-about dt {
  flex: 0 0 9.5rem;
  color: var(--mute);
}

.draft-about dd {
  flex: 1 1 16rem;
}

/* The box a text file is written in. */
.draft-writer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
  overflow: hidden;
}

.draft-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.375rem 1rem;
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--line);
}

.draft-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem;
}

.draft-tool {
  min-height: 44px;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.draft-tool:hover {
  background: var(--pale);
}

.draft-segs .seg span {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
}

.draft-panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.draft-panes.is-both {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.draft-panes.is-both .draft-edit {
  border-right: 1px solid var(--line);
}

.draft-panes.is-write .draft-preview,
.draft-panes.is-preview .draft-edit {
  display: none;
}

@media (max-width: 62rem) {
  .draft-panes.is-both {
    grid-template-columns: minmax(0, 1fr);
  }

  .draft-panes.is-both .draft-edit {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

/* The text and, behind it, a copy of it one element to a line, where the
   numbers are drawn. The two have the same type and the same room, so a
   line that wraps takes the same rows in both. */
.draft-edit {
  --gutter: 3.75rem;
  position: relative;
  min-width: 0;
  background:
    linear-gradient(var(--pale), var(--pale)) left top / var(--gutter) 100% no-repeat,
    var(--surface);
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.7;
}

.draft-lines {
  min-height: 12rem;
  padding: 0.875rem 0;
  counter-reset: line;
  overflow: hidden;
}

.draft-line {
  position: relative;
  padding: 0 1rem 0 calc(var(--gutter) + 0.875rem);
  color: transparent;
  counter-increment: line;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  tab-size: 2;
}

.draft-line::before {
  content: counter(line);
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--gutter) - 0.75rem);
  color: var(--mute);
  text-align: right;
  white-space: nowrap;
}

.draft-line.is-here::before {
  color: var(--ink);
  font-weight: 500;
}

.draft-text {
  position: absolute;
  top: 0;
  left: var(--gutter);
  width: calc(100% - var(--gutter));
  height: 100%;
  margin: 0;
  padding: 0.875rem 1rem 0.875rem 0.875rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  letter-spacing: inherit;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  tab-size: 2;
  resize: none;
  overflow: hidden;
}

.draft-text:focus-visible {
  outline-offset: -3px;
}

/* Where long lines scroll sideways, each line is one row. */
.draft-edit.is-straight .draft-line {
  white-space: pre;
}

.draft-edit.is-straight .draft-lines {
  padding-bottom: 2rem;
}

.draft-edit.is-straight .draft-text {
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.draft-preview {
  min-width: 0;
  padding: 1.25rem 1.5rem 1.5rem;
}

.draft-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.25rem;
  min-height: 44px;
  margin: 0;
  padding: 0 1.125rem;
  border-top: 1px solid var(--line);
  color: var(--mute);
  font-size: 0.9rem;
}

.draft-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  margin-left: auto;
  cursor: pointer;
}

.draft-wrap input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--accent);
}

/* The listing as a form. */
.draft-form {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
  max-width: 54rem;
}

.draft-form > section {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.draft-form h3 {
  font-size: 1.3rem;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.draft-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  gap: 0.875rem 1.25rem;
  align-items: start;
}

.draft .field textarea,
.draft .field input[type="text"] {
  width: 100%;
  border: 1px solid var(--field);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
}

.draft .field textarea {
  padding: 0.625rem 0.875rem;
  font-family: var(--sans);
  line-height: 1.45;
  resize: vertical;
}

.draft .field textarea.is-wrong {
  border: 2px solid var(--fail);
}

.draft .field small.is-fail {
  color: var(--fail);
  font-weight: 600;
}

.draft-id {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  color: var(--mute);
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 400;
}

.draft-id input {
  flex: 1 1 auto;
  min-width: 0;
}

.draft-ticks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
}

.draft-ticks .toggle {
  align-items: center;
}

.draft-ticks .toggle input {
  margin: 0;
}

.draft-shots,
.draft-choices {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.draft-shots li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
}

.draft-shots img,
.draft-shot-missing {
  flex: none;
  width: 7.5rem;
  aspect-ratio: 16 / 10;
  border-radius: 0.625rem;
  background: var(--pale);
  object-fit: cover;
}

.draft-shot-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  color: var(--fail);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.draft-shot-text {
  flex: 1 1 14rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  min-width: 0;
}

.draft-shot-text code {
  overflow-wrap: anywhere;
}

.draft-shot-text .toggle {
  flex: 1 0 100%;
  align-items: center;
}

.draft-shot-text .toggle input {
  margin: 0;
}

.draft-choices li {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
  gap: 0.875rem 1.125rem;
  align-items: start;
  padding: 1rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
}

.draft-choices .toggle {
  align-self: end;
  align-items: center;
}

.draft-choices .toggle input {
  margin: 0;
}

.draft-choice-end {
  grid-column: 1 / -1;
  margin: 0;
}

.draft-form-end {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

/* What an agent in the browser last did to the draft, with a way back. */
.draft-agent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.625rem 0.75rem 0.625rem 1.125rem;
  border-radius: 0.625rem;
  background: var(--panel);
  color: var(--panel-text);
}

.draft-agent p {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.draft-agent .draft-small {
  border-color: var(--panel-text);
  color: var(--panel-text);
}

.draft-agent .draft-small:hover {
  background: var(--panel-text);
  color: var(--panel);
}

/* What is wrong with the draft, under the open file. */
.draft-problems {
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
  overflow: hidden;
}

.draft-problems h2 {
  margin: 0;
  padding: 0.75rem 1.125rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}

.draft-problems .hint {
  margin: 0;
  padding: 0 1.125rem 0.75rem;
}

.draft-problem-list {
  margin: 0;
  padding: 0 1.125rem;
  border-top: 1px solid var(--line);
  list-style: none;
  font-size: 0.95rem;
}

.draft-problem-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.125rem 1rem;
  min-height: 52px;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--line);
}

.draft-problem-list li:last-child {
  border-bottom: 0;
}

.draft-problem-file {
  flex: 0 0 11.5rem;
  overflow-wrap: anywhere;
}

.draft-problem-text {
  flex: 1 1 16rem;
  overflow-wrap: anywhere;
}

.draft-kept {
  margin: 0;
}

/* The panel that opens over the page to publish: Pekk on a panel of sky,
   as on a spec's page. */
.draft-panel {
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 0;
  border-radius: 0.875rem;
  background: transparent;
  color: var(--ink);
  overflow: auto;
}

.draft-panel::backdrop {
  background: rgba(16, 17, 22, 0.55);
}

.draft-panel .dock-top h2 {
  overflow-wrap: anywhere;
}

.draft-panel .dock-line {
  display: flex;
  flex-direction: column;
  font-size: 0.95rem;
}

.draft-panel .dock-line p + p {
  margin-top: 0.5rem;
}

.draft-panel .dock-line p {
  margin: 0;
}

.draft-panel .dock-line code {
  font-size: 0.92rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.draft-panel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.125rem 1rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--mute);
}

.draft-panel-row:last-child {
  border-bottom: 0;
}

.draft-panel-row > span:first-child {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.draft-panel-row.is-strong > span:first-child {
  font-weight: 650;
}

.draft-panel-row progress {
  flex: 1 0 100%;
  height: 0.625rem;
  margin-top: 0.375rem;
  accent-color: var(--accent);
}

.draft-panel-list {
  margin: 0;
  padding-left: 1.125rem;
}

/* The files a publish sends, in the panel that asks. */
.draft-panel-files {
  padding: 0.625rem 0;
  color: var(--mute);
}

.draft-panel-files summary {
  cursor: pointer;
  color: var(--ink);
}

.draft-panel-files .draft-panel-list {
  max-height: 14rem;
  margin-top: 0.375rem;
  padding-left: 0;
  overflow-y: auto;
  list-style: none;
}

.draft-panel-files li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.draft-panel-files li span {
  flex: none;
}

.draft-panel-list li {
  padding: 0.25rem 0;
  overflow-wrap: anywhere;
}

.draft-panel-acts {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.draft-panel-acts .button {
  width: 100%;
  min-height: 52px;
  border-radius: 0.625rem;
  font-size: 1.02rem;
}

.draft-panel-acts .button-quiet {
  border-color: var(--ink);
}
