/* uploads — view-specific rules. Shared primitives live in style.css.
 *
 * Two document plates. This is the one screen in the console that is literally about
 * documents, so it is where the registration offset — the single permitted depth device
 * in this system, hard and with zero blur — belongs: 3px of ink behind each sheet, and
 * nowhere else on the screen.
 *
 * Marking Orange appears exactly twice, on the two primary Upload buttons, both well
 * over 24px. Every refusal on this screen sets in Marking Ink, because a refusal is
 * small text. Every state also prints its word.
 */

#view-uploads {
  max-width: 1000px;
}

/* --------------------------------------------------------------------------
   The plate
   -------------------------------------------------------------------------- */

.up-plate {
  position: relative;
  padding: var(--lg);
  margin-bottom: var(--xl);
  border-color: var(--ink);
  /* The one permitted depth device. Hard, zero blur, a sheet set down on the page. */
  box-shadow: 3px 3px 0 0 var(--ink);
}

.up-plate:last-child {
  margin-bottom: var(--lg);
}

/* Printer's furniture: corner marks, as on a trimmed plate. */
.up-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.up-corner {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 0 solid var(--ink);
}

.up-corner--tl { top: 6px; left: 6px; border-top-width: 1px; border-left-width: 1px; }
.up-corner--tr { top: 6px; right: 6px; border-top-width: 1px; border-right-width: 1px; }
.up-corner--bl { bottom: 6px; left: 6px; border-bottom-width: 1px; border-left-width: 1px; }
.up-corner--br { bottom: 6px; right: 6px; border-bottom-width: 1px; border-right-width: 1px; }

.up-plate > .up-head {
  margin: 0 0 var(--md);
  padding-bottom: var(--sm);
  border-bottom: 2px solid var(--ink);
  font-size: clamp(1.375rem, 3.2vw, 1.875rem);
  font-variation-settings: 'wdth' 112;
  text-transform: uppercase;
  letter-spacing: -0.015em;
}

/* The brief is the rule this card operates under. It is not supporting text, so it does
   not set in the supporting-text grey. */
.up-plate > .up-brief {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
  max-width: 66ch;
  margin-bottom: var(--md);
}

/* --------------------------------------------------------------------------
   The fork: what actually happens to what you upload
   -------------------------------------------------------------------------- */

.up-fork {
  border-top: 1px solid var(--rule);
  margin-bottom: var(--md);
}

.up-fork-row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--md);
  padding: var(--sm) 0;
  border-bottom: 1px solid var(--rule);
}

.up-fork-label {
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  padding-top: 3px;
}

.up-fork-text {
  font-size: 0.9375rem;
  line-height: 1.45;
}

/* The sentence the whole card exists to make legible. */
.up-fork-foot {
  margin: var(--md) 0 0;
  padding: var(--sm) 0 var(--sm) var(--md);
  border-left: 2px solid var(--ink);
  font-size: 1rem;
  font-weight: 600;
  font-variation-settings: 'wdth' 106;
  max-width: 60ch;
}

.up-consequence {
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  padding: var(--md);
  margin-bottom: var(--lg);
}

.up-consequence-label {
  margin: 0 0 var(--xs);
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.up-consequence-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 66ch;
}

/* --------------------------------------------------------------------------
   The dated field, and what happens if it is left empty
   -------------------------------------------------------------------------- */

.up-plate > .up-field {
  max-width: 22rem;
  margin-bottom: var(--xs);
}

/* A financial year is a measured value: 2026/27, not prose. */
#plan-fy {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.up-hint {
  margin: 0 0 var(--md);
  font-size: 0.8125rem;
  color: var(--ink-secondary);
  max-width: 46ch;
}

/* --------------------------------------------------------------------------
   The drop zone
   --------------------------------------------------------------------------
   A <label> wrapping a real, focusable file input. The input is clipped, never removed
   and never display:none — it keeps its place in the tab order, and Space or Enter on it
   opens the picker exactly as it did before this file existed. */

.up-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--md);
  min-height: 200px;
  padding: var(--lg) var(--md);
  margin: 0;
  background: var(--paper-sunk);
  border: 1px dashed var(--rule);
  cursor: pointer;
  text-align: center;
  /* Undo the mono label vocabulary style.css gives every <label>. */
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  transition: border-color 120ms linear, background-color 120ms linear;
}

.up-drop:hover {
  border-color: var(--ink);
}

/* A dropped file is a shape change and a word change, not a colour change. */
.up-drop--over {
  border: 2px solid var(--ink);
  background: var(--paper-lit);
}

.up-drop-prompt {
  max-width: 40ch;
  line-height: 1.4;
}

/* What the card takes, stated before anyone chooses the wrong thing. */
.up-drop-accepts {
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.up-choose {
  display: inline-block;
  border: 1px solid var(--ink);
  background: transparent;
  padding: 9px 15px;
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  transition: background-color 120ms linear, color 120ms linear;
}

.up-drop:hover .up-choose {
  background: var(--ink);
  color: var(--paper-lit);
}

.up-drop input.up-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The clipped input cannot show its own ring, so the zone wears it. */
.up-drop:has(input.up-file:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-color: var(--ink);
}

@supports not selector(:has(*)) {
  .up-drop:focus-within {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
    border-color: var(--ink);
  }
}

/* --------------------------------------------------------------------------
   The selected file, as measured values
   -------------------------------------------------------------------------- */

.up-readout {
  border-bottom: 1px solid var(--rule);
  padding: var(--md) 0;
}

.up-readout-label {
  margin: 0 0 var(--sm);
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.up-readout-grid {
  grid-template-columns: 140px minmax(0, 1fr);
  margin: 0;
}

.up-readout-grid dd {
  overflow-wrap: anywhere;
}

.up-readout-fail {
  margin: 0;
  padding: var(--sm) 0 var(--sm) var(--md);
  border-left: 2px solid var(--mark-ink);
  color: var(--mark-ink);
  font-size: 0.875rem;
  max-width: 60ch;
}

/* --------------------------------------------------------------------------
   Action row and the in-flight meter
   -------------------------------------------------------------------------- */

.up-actions {
  display: flex;
  align-items: center;
  gap: var(--md);
  justify-content: flex-end;
  border-top: 1px solid var(--rule);
  padding-top: var(--md);
  margin-top: var(--md);
}

/* Deliberately indeterminate. app.js posts an ArrayBuffer through fetch, which reports
   no upload progress at all, so there is no percentage to print — and a percentage that
   is not measured is invented data. The word carries the state; the block only says the
   request is still open. See Docs/Design/stitch-console/gaps/uploads.md. */
.up-meter {
  flex: 1 1 auto;
  height: 22px;
  min-width: 80px;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  overflow: hidden;
}

.up-meter-block {
  display: block;
  width: 32%;
  height: 100%;
  background: var(--ink);
  animation: up-travel 1.4s linear infinite;
}

@keyframes up-travel {
  from { transform: translateX(-100%); }
  to { transform: translateX(313%); }
}

/* With motion off the travelling block would freeze at 32% and read as a measurement
   nobody took. Resolve it to a full bar instead; the word still carries the state. */
@media (prefers-reduced-motion: reduce) {
  .up-meter-block {
    width: 100%;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Outcome
   --------------------------------------------------------------------------
   `#gazette-result` and `#plan-result` stay the one aria-live region per card. The
   status word and the note are plain siblings inside this block, so nothing announces
   twice — and every state prints its word, so the left rule is never carrying the
   meaning on its own. */

.up-outcome {
  margin-top: var(--md);
  padding-left: var(--md);
  border-left: 2px solid var(--rule);
}

.up-outcome .result {
  margin: 0;
  padding: 0;
  border-left: 0;
}

.up-status {
  margin: 0 0 var(--xs);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

.up-note {
  margin: var(--sm) 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-secondary);
  max-width: 66ch;
}

.up-outcome[data-kind='accepted'],
.up-outcome[data-kind='inflight'] {
  border-left-color: var(--ink);
}

.up-outcome[data-kind='inflight'] .up-status {
  color: var(--ink-secondary);
}

.up-outcome[data-kind='refused'],
.up-outcome[data-kind='failed'],
.up-outcome[data-kind='warn'] {
  border-left-color: var(--mark-ink);
}

/* Below 24px the signal is Marking Ink, never Marking Orange. */
.up-outcome[data-kind='refused'] .up-status,
.up-outcome[data-kind='failed'] .up-status,
.up-outcome[data-kind='warn'] .up-status {
  color: var(--mark-ink);
}

/* --------------------------------------------------------------------------
   Narrow. Reviewers work from phones, so 320px is a normal case, not an edge one.
   -------------------------------------------------------------------------- */

@media (max-width: 700px) {
  .up-plate {
    padding: var(--md);
    margin-bottom: var(--lg);
  }

  .up-corner { width: 8px; height: 8px; }
  .up-corner--tl, .up-corner--tr { top: 4px; }
  .up-corner--bl, .up-corner--br { bottom: 4px; }
  .up-corner--tl, .up-corner--bl { left: 4px; }
  .up-corner--tr, .up-corner--br { right: 4px; }

  .up-fork-row {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--xs);
  }

  .up-fork-label { padding-top: 0; }

  .up-drop {
    min-height: 148px;
    padding: var(--md) var(--sm);
    gap: var(--sm);
  }

  .up-readout-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0 0;
  }

  .up-readout-grid dt { padding-top: var(--sm); }

  .up-actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sm);
  }

  .up-actions .primary { width: 100%; }
}
