/* CMV_37.0.5_TEST — SYSTEM ONLINE / ARCHIVE FILE EDGE ALIGNMENT
 * Base: 37.0.4 (retains compact controls and all previous view geometry).
 * Left: supplied 36.13.1 heading/copy. Right: 37.0_TEST control treatment.
 * View geometry: supplied 37.1 SOURCE CONSOLIDATION, not the older 37.1_TEST.
 * No shared stylesheets or JavaScript are replaced.
 */

/* GREEN ADD: desktop-only Archive composition. */
@media (min-width: 1180px) {
  #archive {
    --cmv373-view-field: 1460px;
    /* Keep the existing page inset; align the header to the files below. */
    padding-right: 34px !important;
  }

  #archive .archive-system {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding-left: clamp(30px, 3.2vw, 56px) !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
  }

  #archive .archive-header {
    width: 100% !important;
    max-width: var(--cmv375-header-field, var(--cmv373-view-field)) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(440px, 670px) !important;
    gap: 38px !important;
    align-items: start !important;
  }

  /* Keep the existing title, wording, typography, and left-column text measure. */
  #archive .archive-header > div:first-child {
    display: block !important;
    min-width: 0;
  }

  #archive .archive-header > div:first-child > small,
  #archive .archive-header > div:first-child > .section-title,
  #archive .archive-header > div:first-child > .portfolio-copy {
    display: block !important;
  }

  #archive .archive-side-controls-v12 {
    position: static !important;
    width: 100% !important;
    max-width: 670px !important;
    min-width: 0 !important;
    margin-top: 36px !important;
    justify-self: end !important;
    justify-items: end !important;
    gap: 16px !important;
  }

  #archive .archive-system-status-v12,
  #archive .archive-view-toggle-v12,
  #archive .archive-memo-top {
    /* Restore the original intrinsic sizes instead of filling the 670px rail. */
    width: auto !important;
    max-width: 100% !important;
    justify-self: end !important;
    box-sizing: border-box !important;
  }

  #archive .archive-system-status-v12 {
    /* Exact reference length; do not allow content to stretch this bar. */
    width: 410px !important;
    min-height: 46px !important;
    min-width: 410px !important;
  }

  #archive .archive-view-toggle-v12 {
    display: flex !important;
    gap: 0 !important;
  }

  #archive .archive-view-toggle-v12 .view-btn {
    padding: 0 20px !important;
  }

  #archive .archive-memo-top {
    width: max-content !important;
    display: flex !important;
    justify-content: flex-end !important;
    flex-wrap: wrap !important;
    gap: 10px 28px !important;
    white-space: normal !important;
  }

  #archive .archive-memo-top span {
    max-width: 100%;
    white-space: normal !important;
  }

  /* Source Consolidation field sizes; original card internals are identical. */
  #archive #archiveDirectory.view-list,
  #archive #archiveDirectory.view-wide-list,
  #archive #archiveDirectory.view-tiles,
  #archive #archiveDirectory.view-grid {
    width: 100% !important;
    max-width: var(--cmv373-view-field) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Large is the 37.1 single-dossier row, NOT a three-column large-card grid. */
  #archive #archiveDirectory.view-large {
    width: 100% !important;
    max-width: 1240px !important;
    grid-template-columns: 1fr !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Large has a narrower ordinary-desktop field; follow its file edge too. */
  #archive:has(#archiveDirectory.view-large) {
    --cmv375-header-field: 1240px;
  }

  /* Stabilize the original active-only card inset during page fades. */
  #archive .archive-dossier {
    padding-left: 18px !important;
  }

  #archive .archive-directory.view-grid .archive-dossier,
  #archive .archive-directory.view-large .archive-dossier {
    padding-left: 22px !important;
  }
}

/* Keep the heading readable rather than forcing both columns into a tight row. */
@media (min-width: 1180px) and (max-width: 1599px) {
  #archive .archive-header {
    grid-template-columns: minmax(0, 1fr) !important;
    row-gap: 18px !important;
  }

  #archive .archive-side-controls-v12 {
    margin-top: 0 !important;
  }
}

/* Source Consolidation's ultrawide view field, including Large. */
@media (min-width: 2200px) {
  #archive {
    --cmv373-view-field: 1800px;
  }

  #archive #archiveDirectory.view-large {
    max-width: 1800px !important;
  }

  #archive:has(#archiveDirectory.view-large) {
    --cmv375-header-field: var(--cmv373-view-field);
  }
}

/* Same motion policy as the 37.0.1 repair; do not replace normal page fades. */
@media (prefers-reduced-motion: reduce) {
  #archive.screen {
    transition: none !important;
  }
}
