/* Bundle of Authorities Autobot: the tool page (site/open-source/autobot/).
   Loaded after site.css and tools.css (the pieces all tool pages share), and built from the same tokens:
   Carbon panels, Graphite hairlines, mono labels, Brass as ink, one ivory button in view at a time.
   The rules are in DESIGN.md. */

/* ---------- Steps ---------- */

.steps { display: flex; flex-direction: column; gap: 24px; }

.step { scroll-margin-top: 108px; background: var(--carbon); border: 1px solid var(--graphite); }

.step__head {
  padding: 22px 32px;
  border-bottom: 1px solid var(--graphite);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}
.step__heading { display: flex; align-items: baseline; gap: 18px; }
.step__num { font-family: var(--mono); font-size: 12px; color: var(--brass); white-space: nowrap; }
.step__title { font-family: var(--serif); font-size: 30px; font-weight: 400; line-height: 1.1; letter-spacing: -0.01em; }
.step__title:focus { outline: none; }
.step__state { font-size: 11px; }

.step__body { padding: 28px 32px 32px; }
.step__intro { max-width: 760px; font-size: 15px; line-height: 1.6; color: var(--ash); }

.step__actions { margin-top: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; }

/* ---------- 01: upload ---------- */

.dropzone {
  position: relative;
  margin-top: 24px;
  min-height: 220px;
  padding: 32px 24px;
  border: 1px dashed var(--graphite-2);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.3s, background-color 0.3s, opacity 0.3s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brass); }
.dropzone.is-over { background: var(--light); }
.dropzone:focus-within { outline: 2px solid var(--brass); outline-offset: 3px; }
.dropzone.is-locked { opacity: 0.4; cursor: not-allowed; }
.dropzone.is-locked:hover { border-color: var(--graphite-2); }
.dropzone__title { font-family: var(--serif); font-size: 32px; line-height: 1.15; }
.dropzone__meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ash);
}
.dropzone__btn { margin-top: 8px; pointer-events: none; }
.dropzone__file { margin-top: 4px; font-family: var(--mono); font-size: 13px; color: var(--stone); overflow-wrap: anywhere; }

.upload-summary { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px 24px; }
.upload-summary__file { font-family: var(--mono); font-size: 14px; color: var(--stone); overflow-wrap: anywhere; }

.tally {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--graphite);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}
.tally div { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 6px; }
.tally dt {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ash);
}
.tally dd { font-family: var(--serif); font-size: 48px; line-height: 1; }

/* ---------- 02: cover page ---------- */

.cover { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 40px; align-items: start; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field--wide { grid-column: 1 / -1; }
.field__label {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ash);
}

.field__input,
.tier-select {
  width: 100%;
  background: var(--obsidian);
  border: 1px solid var(--graphite-2);
  border-radius: var(--radius);
  color: var(--ivory);
  font: inherit;
  transition: border-color 0.2s;
}
.field__input { min-height: 48px; padding: 12px 14px; font-size: 15px; line-height: 1.5; }
textarea.field__input { resize: vertical; scrollbar-width: thin; scrollbar-color: var(--graphite-2) transparent; }
.field__input::placeholder { color: #7F7A71; font-style: italic; }
.field__input:hover, .tier-select:hover { border-color: var(--ash); }
.field__input:focus, .tier-select:focus { outline: none; border-color: var(--brass); }

.cover-figure { position: sticky; top: 108px; display: flex; flex-direction: column; gap: 12px; }
.cover-figure .meta { font-size: 11px; }

/* The cover page on Paper, set the way the Word file sets it. */
.cover-sheet {
  min-height: 520px;
  padding: 40px 30px 32px;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-family: 'Times New Roman', Times, serif;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}
.cs-strong { font-weight: 700; text-transform: uppercase; }
.cs-lines { white-space: pre-line; }
.cs-matter { font-style: italic; }
.cs-muted { color: var(--ink-2); }
.cs-title { margin-top: 10px; font-size: 14px; }
.cs-parties { display: flex; flex-direction: column; gap: 2px; }
.cs-gap { height: 10px; }
.cs-sols {
  width: 100%;
  margin-top: auto;
  padding-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  font-family: Calibri, 'Geist', Arial, sans-serif;
  font-size: 9.5px;
  text-align: left;
  white-space: pre-line;
}

/* ---------- 03: order of sections ---------- */

.groups { margin-top: 24px; border-top: 1px solid var(--graphite); }

.group {
  padding: 12px 0;
  border-bottom: 1px solid var(--graphite);
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 20px;
}
.group__pos { font-family: var(--mono); font-size: 12px; color: var(--brass); }
.group__name { font-size: 16px; }
.group__meta { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ash); white-space: nowrap; }
.group.is-empty .group__name { color: var(--ash); }
.group__moves { display: flex; gap: 6px; }

.move {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--graphite-2);
  border-radius: var(--radius);
  color: var(--ivory);
  font-size: 14px;
  transition: border-color 0.2s;
}
.move:not(:disabled):hover { border-color: var(--ash); }
.move:disabled { opacity: 0.25; cursor: default; }

@keyframes moved { from { background-color: rgba(184, 152, 92, 0.1); } }
.group.is-moved { animation: moved 1.2s var(--ease); }

.combine { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 14px 40px; }

/* ---------- 04: review ---------- */

.review-wrap { margin-top: 20px; }

.review { width: 100%; border-collapse: collapse; font-size: 14px; }
.review th {
  padding: 14px 12px;
  border-bottom: 1px solid var(--graphite-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-align: left;
  text-transform: uppercase;
  color: var(--ash);
}
.review td { padding: 16px 12px; border-bottom: 1px solid var(--graphite); vertical-align: top; }
.review th:first-child, .review td:first-child { padding-left: 0; }
.review th:last-child, .review td:last-child { padding-right: 0; }
.review .c-inc { width: 64px; }
.review .c-tier { width: 230px; }
.review .c-pins { width: 150px; }
.review .c-status { width: 230px; }
.review tr { transition: opacity 0.3s; }

.auth__title { font-size: 15px; line-height: 1.5; color: var(--parchment); }
.auth__citation { margin-top: 4px; font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--ash); overflow-wrap: anywhere; }
.auth__relevance { margin-top: 8px; font-size: 13px; font-style: italic; line-height: 1.5; color: var(--ash); }

.pins { font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--stone); }
.pins--none { font-family: var(--sans); font-size: 13px; color: var(--ash); }

.tier-select {
  appearance: none;
  -webkit-appearance: none;
  height: 36px;
  padding: 0 30px 0 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='none' stroke='%239C978D' stroke-width='1.2'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 10px 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--stone);
}

.status { font-family: var(--mono); font-size: 11px; line-height: 1.5; letter-spacing: 0.1em; text-transform: uppercase; }
.status--verified { color: var(--brass); }
.status--placeholder { color: var(--ash); }
.status--pending { color: var(--stone); }
.status--excluded { color: var(--ash); }
.status__note { margin-top: 6px; font-size: 12px; line-height: 1.45; color: var(--ash); overflow-wrap: anywhere; }

.review tr.is-excluded td:not(:first-child) { opacity: 0.42; }

.legend {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ash);
}
.legend span { margin-right: 6px; font-family: var(--mono); }

@media (hover: hover) and (pointer: fine) {
  .review tbody tr:hover td { background: rgba(236, 231, 221, 0.018); }
}

/* ---------- 05: build ---------- */

.build {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 48px 44px;
  background: var(--carbon);
  border: 1px solid var(--graphite);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px 48px;
}
.build::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(55% 110% at 90% 120%, rgba(184, 152, 92, 0.13), transparent 70%);
}
.build::after {
  content: "§";
  position: absolute;
  z-index: -1;
  right: 4%;
  top: 50%;
  font-family: var(--serif);
  font-size: 300px;
  line-height: 1;
  color: rgba(236, 231, 221, 0.035);
  transform: translateY(-52%);
  pointer-events: none;
}
.build__text { max-width: 620px; }
.build__title { margin-top: 14px; font-family: var(--serif); font-size: 48px; font-weight: 400; line-height: 1; letter-spacing: -0.015em; }
.build__lead { margin-top: 16px; font-size: 16px; line-height: 1.6; color: var(--ash); }
.build__action { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; }
.build__action .tool-note { max-width: 340px; text-align: right; }

/* ---------- Tablet ---------- */

@media (max-width: 1100px) {
  .review .c-tier { width: 190px; }
  .review .c-status { width: 190px; }
  .review .c-pins { width: 120px; }
}

@media (max-width: 900px) {
  .cover { grid-template-columns: minmax(0, 1fr); }
  .cover-figure { position: static; max-width: 420px; }
  .build { flex-direction: column; align-items: flex-start; }
  .build__action { align-items: flex-start; }
  .build__action .tool-note { text-align: left; }
}

/* ---------- Phone ---------- */

@media (max-width: 760px) {
  .step { scroll-margin-top: 80px; }
  .step__head { padding: 18px 20px; }
  .step__heading { gap: 12px; }
  .step__title { font-size: 25px; }
  .step__body { padding: 22px 20px 26px; }

  .dropzone { min-height: 190px; }
  .dropzone__title { font-size: 26px; }
  .step__actions .btn--primary { width: 100%; }

  .tally { gap: 12px; }
  .tally dd { font-size: 34px; }
  .tally dt { font-size: 10px; letter-spacing: 0.1em; }

  .fields { grid-template-columns: minmax(0, 1fr); }
  .field--wide { grid-column: auto; }
  .cover-sheet { min-height: 0; padding: 32px 20px 26px; }

  .group { grid-template-columns: 32px minmax(0, 1fr) auto; grid-template-areas: "pos name moves" "pos meta moves"; row-gap: 2px; }
  .group__pos { grid-area: pos; }
  .group__name { grid-area: name; font-size: 15px; }
  .group__meta { grid-area: meta; font-size: 10px; }
  .group__moves { grid-area: moves; }

  /* The review table becomes one block per authority. */
  .review thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .review, .review tbody, .review tr, .review td { display: block; }
  .review tr {
    padding: 18px 0;
    border-bottom: 1px solid var(--graphite);
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 10px;
  }
  .review td { padding: 0 !important; border: 0; }
  .review td:first-child { grid-row: 1 / span 4; }
  .review .c-tier, .review .c-pins, .review .c-status { width: auto; }
  .tier-select { max-width: 280px; }

  .build { padding: 32px 22px; }
  .build::after { font-size: 220px; right: -4%; }
  .build__title { font-size: 36px; }
  .build__action, .build__action .btn { width: 100%; }
}
