/* AragoCor Minerals — the /resources document library and its reader
 *
 * The rows are the controlled-document list: a mono control number, a serif
 * title, one line of meta, and two actions. Read opens the document's own page
 * in place, in a full-window reader over the list; PDF saves the file.
 * `document-library.js` builds the reader and owns its behaviour. The rows are
 * real links and the PDF link carries `download`, so the library works with
 * scripts off — a click then simply navigates to the document page.
 *
 * Tokens: the `--ac-*` names from `site-chrome.css` are guaranteed on every
 * page. The design-system names (`--paper`, `--border`, `--tide`, `--fg-2`,
 * `--font-serif`) carry a fallback, so the component renders the same if it is
 * ever moved to a page that does not load `_ds/`.
 */

/* ---------- The library ---------- */

.ac-doclib {
  container: doclib / inline-size;
  background: var(--paper, #FFFFFF);
  border: 1px solid var(--border, #C7CBC6);
  border-radius: 8px;
  overflow: hidden;
  color: var(--ac-ink);
  font-family: var(--ac-font-sans);
}
.ac-doclib__list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.ac-doclib__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  border-top: 1px solid var(--ink-08, rgba(14, 53, 64, 0.08));
}
.ac-doclib__item:first-child { border-top: 0; }

/* The row itself is the Read link: control number, copy, then the affordance. */
.ac-doclib__doc {
  min-width: 0;
  min-height: 44px;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  color: var(--ac-ink);
  text-decoration: none;
  transition: background 220ms var(--ac-ease);
}
.ac-doclib__id {
  white-space: nowrap;
  font-family: var(--ac-font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--tide, #526A70);
  transition: color 220ms var(--ac-ease);
}
.ac-doclib__copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.ac-doclib__title {
  font-family: var(--font-serif, "Source Serif 4", Georgia, serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  overflow-wrap: break-word;
}
.ac-doclib__meta {
  font-family: var(--ac-font-mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  line-height: 1.45;
  color: var(--fg-2, #526A70);
  transition: color 220ms var(--ac-ease);
}
.ac-doclib__read {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--ac-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--tide, #526A70);
  transition: color 220ms var(--ac-ease);
}
.ac-doclib__read svg,
.ac-doclib__pdf svg {
  flex: 0 0 auto;
  transition: transform 220ms var(--ac-ease);
}

/* The PDF link sits in its own column so the two actions never share a target. */
.ac-doclib__pdf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 44px;
  padding: 0 20px;
  border-left: 1px solid var(--ink-08, rgba(14, 53, 64, 0.08));
  font-family: var(--ac-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--tide, #526A70);
  text-decoration: none;
  transition: background 220ms var(--ac-ease), color 220ms var(--ac-ease);
}
.ac-doclib__doc:focus-visible,
.ac-doclib__pdf:focus-visible {
  outline: 2px solid var(--ac-ink);
  outline-offset: -3px;
}
.ac-doclib__hint {
  margin: 12px 0 0;
  font-family: var(--ac-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--fg-3, #627178);
}
/* "Here" is the reader, and the reader is for pointer devices: on a touch
   device Read opens the document's own page (see `framesInPlace` in
   `document-library.js`), so the promise is dropped rather than broken. */
@media (pointer: coarse) {
  .ac-doclib__inplace { display: none; }
}

@media (hover: hover) {
  .ac-doclib__doc:hover { background: var(--ac-sand); }
  .ac-doclib__doc:hover .ac-doclib__id,
  .ac-doclib__doc:hover .ac-doclib__meta,
  .ac-doclib__doc:hover .ac-doclib__read { color: var(--ac-ink); }
  .ac-doclib__doc:hover .ac-doclib__read svg { transform: translateX(2px); }
  .ac-doclib__pdf:hover {
    background: var(--ac-sand);
    color: var(--ac-ink);
  }
  .ac-doclib__pdf:hover svg { transform: translateY(2px); }
}

/* The library sits in a column, not the viewport, so it responds to its own
   width. In the /resources split that column is about 490px on a laptop, where
   a fixed 108px identifier track left roughly 150px for the title: control
   numbers broke mid-token ("TDS-OA-" / "001") and the meta line ran to three.
   Stacking the identifier above the copy gives the text the full width back. */
@container doclib (max-width: 620px) {
  .ac-doclib__doc {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 4px;
  }
  .ac-doclib__id {
    grid-column: 1 / -1;
    margin-bottom: 2px;
  }
}

@media (max-width: 600px) {
  .ac-doclib__doc {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: 14px 16px;
  }
  .ac-doclib__read {
    justify-self: start;
    margin-top: 2px;
  }
  .ac-doclib__pdf { padding: 0 14px; }
  /* Read and PDF are the only two controls on a row; 10.5px tracked capitals
     are below the floor the rest of the site holds to on a phone. */
  .ac-doclib__read,
  .ac-doclib__pdf { font-size: 11.5px; }
}

/* ---------- The reader ----------
 *
 * Built by `document-library.js`. Fills the window, so a Letter page renders at
 * true size on a desktop and the framed document's own responsive rules take
 * over on a phone. The frame stays invisible until it has loaded: the framed
 * page hides its header and footer from a deferred script, and revealing it
 * only on `load` means that chrome is never seen.
 */

.ac-reader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--ac-bone);
  color: var(--ac-bone);
  font-family: var(--ac-font-sans);
}
.ac-reader[hidden] { display: none; }
.ac-reader__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--ac-ink);
  border-bottom: 1px solid rgba(247, 244, 237, 0.14);
}
.ac-reader__who {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
}
.ac-reader__id {
  font-family: var(--ac-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ac-sand);
}
.ac-reader__id[hidden] { display: none; }
.ac-reader__title {
  max-width: 100%;
  font-family: var(--font-serif, "Source Serif 4", Georgia, serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-reader__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  background: none;
  color: var(--ac-bone);
  border: 1px solid rgba(247, 244, 237, 0.35);
  border-radius: 4px;
  font: 500 10.5px/1 var(--ac-font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 220ms var(--ac-ease), border-color 220ms var(--ac-ease);
}
.ac-reader__btn:hover {
  background: rgba(247, 244, 237, 0.12);
  border-color: var(--ac-sand);
}
.ac-reader__btn:focus-visible {
  outline: 2px solid var(--ac-sand);
  outline-offset: 2px;
}
.ac-reader__btn--primary {
  border-color: var(--ac-sand);
  color: var(--ac-sand);
}
/* `hidden` is a UA-stylesheet rule and the author `display: inline-flex` above
   beats it, so the attribute alone leaves the button on screen. The reader hides
   its download control for a row that has no PDF of its own — the web summary is
   one — and without this that control stays visible with no href behind it. */
.ac-reader__btn[hidden] { display: none !important; }
.ac-reader__body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}
.ac-reader__status {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ac-font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tide, #526A70);
}
.ac-reader__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--ac-bone);
  opacity: 0;
  transition: opacity 240ms var(--ac-ease);
}
.ac-reader.is-loaded .ac-reader__frame { opacity: 1; }
.ac-reader.is-loaded .ac-reader__status { display: none; }
body.ac-reader-open { overflow: hidden; }

@media (max-width: 560px) {
  .ac-reader__bar {
    padding: 8px 12px;
    gap: 8px;
  }
  .ac-reader__title { display: none; }
  .ac-reader__btn { padding: 0 10px; }
  .ac-reader__btn--print { display: none; }
  .ac-reader__id { font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .ac-doclib__doc,
  .ac-doclib__id,
  .ac-doclib__meta,
  .ac-doclib__read,
  .ac-doclib__read svg,
  .ac-doclib__pdf,
  .ac-doclib__pdf svg,
  .ac-reader__btn,
  .ac-reader__frame { transition: none; }
}
