/* ============================================================
   BUREAU OF LOST TIMELINES — SYSTEM ARCHIVE SHEET
   Version: 2.0 (Dossier system)

   backup.html is the records office of the Bureau: it counts what the
   device is holding and moves it in and out as paper. The page is
   therefore mostly ink and red, with exactly one green moment — the
   storage census, which is a machine reading its own memory. The
   import well is where untrusted JSON is described back before being
   applied, so its summary is a printed manifest, not a chat bubble.

   Colour, size and spacing come from css/tokens.css. No hex values,
   no emoji: destructive blocks are marked by a hazard stripe, the gate
   by a seal plate.
   ============================================================ */

.backup-main {
  max-width: var(--maxw-narrow);
  margin: 0 auto;
  padding: var(--s-5) var(--gutter) var(--s-8);
}

/* ---------- the gate (rank below Chairman) ---------- */
.backup-gate {
  display: none;
  text-align: center;
  padding: var(--s-7) var(--s-3);
}

.backup-gate-inner {
  display: inline-block;
  background: var(--alert-wash);
  border: 1px solid var(--line-red);
  border-left: var(--spine) solid var(--alert);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-1);
  padding: var(--s-6) var(--s-5);
  max-width: 460px;
}

/* The plate a sealed folder carries. */
.gate-seal {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  margin: 0 auto var(--s-4);
  border: 2px solid var(--alert);
  box-shadow: inset 0 0 0 1px var(--alert-deep);
  border-radius: var(--r-1);
  transform: rotate(-3deg);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-label);
  letter-spacing: var(--tr-label);
  color: var(--alert-bright);
}

.backup-gate-inner h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-h3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--alert-bright);
  margin-bottom: var(--s-2);
}

.backup-gate-inner p {
  font-family: var(--font-my);
  font-size: var(--fs-label);
  line-height: 1.7;
  color: var(--paper-dim);
}

/* ---------- the three operations ---------- */
.backup-section {
  position: relative;
  background: var(--ink-1);
  background-image: var(--fibre);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-1);
  padding: var(--s-4);
  margin-bottom: var(--s-4);
}

.backup-section h2 {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--paper-bright);
  margin-bottom: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: var(--spine) solid var(--alert);
}

/* The last section is the only one that can unmake the archive. */
.backup-section.is-danger {
  background-color: var(--ink-1);
  background-image: var(--fibre),
                    linear-gradient(var(--alert-wash), var(--alert-wash));
  border-color: var(--alert-deep);
}

.backup-section.is-danger h2 {
  color: var(--alert-bright);
}

.section-desc {
  font-size: var(--fs-label);
  line-height: var(--lh-body);
  color: var(--muted-strong);
  margin-bottom: var(--s-1);
}

.section-desc-my {
  font-family: var(--font-my);
  font-size: var(--fs-label);
  line-height: 1.7;
  color: var(--paper);
  margin-bottom: var(--s-3);
}

/* ---------- the census ---------- */
.backup-stats {
  margin-bottom: var(--s-3);
}

.backup-warn {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: 1.6;
  letter-spacing: var(--tr-mono);
  text-transform: uppercase;
  color: var(--folklore);
  background: var(--folklore-wash);
  border: 1px solid var(--folklore-line);
  border-left: var(--spine) solid var(--folklore);
  border-radius: var(--r-1);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-3);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: var(--s-1);
}

.stat-item {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  box-shadow: var(--shadow-inset);
  padding: var(--s-2) var(--s-1);
  text-align: center;
}

.stat-item-val {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-h3);
  line-height: 1.1;
  color: var(--phosphor);
  text-shadow: 0 0 12px var(--phosphor-wash);
}

.stat-item-label {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--muted);
  margin-top: var(--s-1);
}

/* ---------- the actions ---------- */
.backup-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
}

.backup-btn {
  background: transparent;
  border: 1px solid var(--alert);
  border-radius: var(--r-1);
  color: var(--alert-bright);
  padding: 11px var(--s-3);
  min-height: 40px;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: var(--tr-mono);
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease),
              box-shadow var(--dur-2) var(--ease);
}

.backup-btn:hover:not(:disabled) {
  background: var(--alert);
  color: var(--ink-0);
  box-shadow: 0 8px 20px var(--alert-glow);
}

.backup-btn:focus-visible {
  outline: 2px solid var(--alert-bright);
  outline-offset: 3px;
}

.backup-btn.danger {
  border-color: var(--alert-deep);
  color: var(--paper-bright);
  background-image: repeating-linear-gradient(
      -45deg,
      var(--alert-wash) 0 6px,
      transparent 6px 12px);
}

.backup-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------- the import ---------- */
.backup-file {
  /* The label is the control; the input stays reachable for keyboards. */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.backup-file-label {
  display: block;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-1);
  color: var(--paper-dim);
  padding: var(--s-3);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--tr-mono);
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  margin-bottom: var(--s-2);
  transition: border-color var(--dur-1) var(--ease),
              background var(--dur-1) var(--ease);
}

.backup-file-label:hover {
  border-color: var(--alert);
  background: var(--alert-wash);
  color: var(--paper-bright);
}

.backup-file:focus-visible + .backup-file-label {
  outline: 2px solid var(--alert-bright);
  outline-offset: 3px;
}

.backup-import-preview {
  margin-bottom: var(--s-3);
}

/* A backup that parsed is described like a manifest: what the machine
   found, in the margin of a rail. */
.import-summary {
  border-left: var(--spine) solid var(--phosphor-dim);
  background: var(--ink-2);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  box-shadow: var(--shadow-inset);
  padding: var(--s-2) var(--s-3);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: 1.9;
  letter-spacing: var(--tr-mono);
  text-transform: uppercase;
  color: var(--muted-strong);
  overflow-wrap: anywhere;
}

.import-summary div:first-child {
  color: var(--paper-bright);
  margin-bottom: var(--s-1);
}

/* A file that did not parse is an error, and errors are red. */
.import-error {
  border-left: var(--spine) solid var(--alert);
  background: var(--alert-wash);
  border-radius: 0 var(--r-1) var(--r-1) 0;
  padding: var(--s-2) var(--s-3);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  line-height: 1.8;
  letter-spacing: var(--tr-mono);
  text-transform: uppercase;
  color: var(--alert-bright);
  overflow-wrap: anywhere;
}

/* ---------- narrow screens ---------- */
@media (max-width: 560px) {
  .backup-gate-inner {
    padding: var(--s-5) var(--s-3);
  }

  .backup-btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .backup-btn,
  .backup-file-label {
    transition: none;
  }
}
