/* ==========================================================================
   Francis Davis Millet Institute - Work page (view "work": one work of the
   Gallery). Figma: frame 46:88 "Page 3 · Work page (A Broadway Milkmaid)".
   Loaded after tokens.css and base.css.
   Template: single-gallery-page.php. Script: assets/js/work.js.

   Copy of build/work/work.css. What the theme changed:
   - the three notes to the client are gone with their styles (the line
     beside the back link, the line under "View larger", the "Not shown"
     panel);
   - the picture column (.fdm-work__figure) now holds the picture block
     (.fdm-work__picture: picture, "View larger", caption) and, when a work
     has more than one picture, a row of small pictures (.fdm-work__thumbs).
     That row is not drawn in Figma;
   - the password form of a protected work sits where the facts would be.

   Contents
    1. Page values         5. Sections
    2. Back link           6. Cite this work
    3. Picture and layout  7. Previous / next
    4. Title and facts     8. Larger view (lightbox)
   ========================================================================== */

/* 1. Page values ----------------------------------------------------------- */

/* Sizes drawn in the Work frame that tokens.css does not carry yet. They are
   kept here because base/ is shared; move them into tokens.css when it is
   next opened. */
.fdm-work,
.fdm-lightbox {
  --fdm-work-title-size: clamp(36px, 30.0571px + 1.52381vw, 52px); /* 36 at 390, 52 at 1440 */
  --fdm-work-lh-19-loose: 31px;   /* 19 / 165% as drawn (tokens.css has 32px) */
  --fdm-work-lh-20: 30px;         /* 20 / 150% */
  --fdm-work-space-13: 13px;      /* fact row padding */
  --fdm-work-label-col: 170px;    /* fact label column */
  --fdm-work-value-max: 500px;    /* fact value column */
  --fdm-work-measure: 700px;      /* reading width of the sections */
  --fdm-work-image-max: 420px;    /* picture column at 1440 */
  --fdm-work-col-gap: clamp(40px, 5vw, 72px);  /* 72 at 1440 */
  --fdm-work-touch: 44px;         /* close button */
  --fdm-work-btn-sm: 35px;        /* height of the small Copy button */
}

/* 2. Back link ------------------------------------------------------------- */

.fdm-work__back {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--fdm-space-10);
  row-gap: var(--fdm-space-4);
  padding-block: var(--fdm-space-36) var(--fdm-space-28);
}

/* Small italic line: the picture caption */
.fdm-work__caption {
  font-size: var(--fdm-fs-15);
  line-height: var(--fdm-lh-15);
  font-style: italic;
  color: var(--fdm-color-text-muted);
  overflow-wrap: break-word;
}

/* 3. Picture and layout ---------------------------------------------------- */

/* 420 / 724 with a 72px gap at 1440 */
.fdm-work__layout {
  display: grid;
  grid-template-columns: minmax(0, 420fr) minmax(0, 724fr);
  column-gap: var(--fdm-work-col-gap);
  align-items: start;
  padding-bottom: var(--fdm-space-64);
}

/* A page with no picture column (a record the data layer does not know). */
.fdm-work__layout--plain {
  grid-template-columns: minmax(0, 1fr);
}

/* The picture column: the picture block, then the row of small pictures. */
.fdm-work__figure {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--fdm-space-20);
  min-width: 0;
}

/* Picture, "View larger", caption: 14px apart as drawn. */
.fdm-work__picture {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--fdm-space-14);
  width: 100%;
  min-width: 0;
}

/* The whole picture, never cropped: the width is set, the height follows. */
.fdm-work__image {
  width: 100%;
  height: auto;
}

/* More pictures of the same work, four to a row. Each sits whole inside a
   square frame; the one shown large has the dark frame. */
.fdm-work__thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--fdm-space-12);
  width: 100%;
}

.fdm-work__thumbs-item {
  min-width: 0;
}

.fdm-work__thumb {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-6);
  color: var(--fdm-color-text-muted);
  text-decoration: none;
}

.fdm-work__thumb-frame {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border: var(--fdm-border);
  border-radius: var(--fdm-radius-image);
  background: var(--fdm-color-surface-alt);
  transition: border-color var(--fdm-duration) var(--fdm-ease);
}

.fdm-work__thumb-image {
  position: absolute;
  top: var(--fdm-space-6);
  left: var(--fdm-space-6);
  width: calc(100% - 2 * var(--fdm-space-6));
  height: calc(100% - 2 * var(--fdm-space-6));
  object-fit: contain;
}

.fdm-work__thumb:hover .fdm-work__thumb-frame {
  border-color: var(--fdm-color-border-strong);
}

.fdm-work__thumb[aria-current="true"] .fdm-work__thumb-frame {
  border-color: var(--fdm-color-border-strong);
  box-shadow: inset 0 0 0 var(--fdm-border-width) var(--fdm-color-border-strong);
}

/* A small picture's own caption. Shown under it when there is no script;
   with the script it appears under the large picture instead, so here it is
   kept for screen readers only. */
.fdm-work__thumb-caption {
  font-size: var(--fdm-fs-13);
  line-height: var(--fdm-lh-140);
  font-style: italic;
  overflow-wrap: anywhere;
}

html.fdm-js .fdm-work__thumbs--swap .fdm-work__thumb-caption {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A work with no picture: the shared "No image available" panel fills the
   picture column. */
.fdm-work__noimage {
  width: 100%;
}

.fdm-work__body {
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-28);
  min-width: 0;
}

/* 4. Title and facts ------------------------------------------------------- */

/* 52/108% at 1440 (56px line), 36/108% at 390 (39px line) */
.fdm-work__title {
  font-size: var(--fdm-work-title-size);
  line-height: var(--fdm-lh-108);
  line-height: round(1.08em, 1px);
  overflow-wrap: break-word;
}

.fdm-work__facts {
  border-top: var(--fdm-border);
}

/* One row: label 170, gap 24, value up to 500. 56px tall with one line. */
.fdm-work__fact {
  display: grid;
  grid-template-columns: var(--fdm-work-label-col) minmax(0, var(--fdm-work-value-max));
  column-gap: var(--fdm-space-24);
  align-items: start;
  padding-block: var(--fdm-work-space-13);
  border-bottom: var(--fdm-border);
}

.fdm-work__fact dd {
  font-size: var(--fdm-fs-19);
  line-height: var(--fdm-lh-19);
  overflow-wrap: break-word;
}

/* 5. Sections -------------------------------------------------------------- */

.fdm-work__section {
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-12);
}

/* Section heading: 30/120% */
.fdm-work__heading {
  font-size: var(--fdm-fs-30);
  line-height: var(--fdm-lh-30-loose);
}

/* Section text: 19/165%, 700px wide, 12px between paragraphs */
.fdm-work__prose {
  max-width: var(--fdm-work-measure);
  font-size: var(--fdm-fs-19);
  line-height: var(--fdm-work-lh-19-loose);
  overflow-wrap: break-word;
}

.fdm-work__prose > * + * {
  margin-top: var(--fdm-space-12);
}

/* A protected work: WordPress's password form (styled in base.css) stands
   where the facts and the text would be. */
.fdm-work__locked {
  width: 100%;
}

/* 6. Cite this work -------------------------------------------------------- */

/* White card, 24px padding: label and Copy button, then the citation */
.fdm-work__cite {
  --fdm-card-padding: var(--fdm-space-24);
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-10);
}

.fdm-work__cite-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--fdm-space-12);
  min-height: var(--fdm-work-btn-sm);
}

/* 11px below the top of the 35px row, as drawn (not 10.5px). */
.fdm-work__cite-label {
  margin-top: 1px;
  color: var(--fdm-color-heading);
}

.fdm-work__citation {
  overflow-wrap: anywhere;
}

/* The button only works with JavaScript. */
html:not(.fdm-js) [data-fdm-copy] {
  display: none;
}

/* 7. Previous / next ------------------------------------------------------- */

.fdm-work__pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--fdm-space-24);
  row-gap: var(--fdm-space-24);
  padding-block: var(--fdm-space-28) var(--fdm-space-72);
}

.fdm-work__pager-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--fdm-space-6);
  min-width: 0;
  padding-top: var(--fdm-space-24);
  border-top: var(--fdm-border);
}

.fdm-work__pager-item--prev {
  grid-column: 1;
}

/* The next work keeps the right-hand column even when there is no previous one. */
.fdm-work__pager-item--next {
  grid-column: 2;
  align-items: flex-end;
  text-align: right;
}

.fdm-work__pager-label {
  color: var(--fdm-color-text-muted);
}

/* Raleway has no arrow glyphs. The arrow is set in the body font, which
   carries them, so it looks the same on every system. */
.fdm-work__pager-arrow {
  margin-inline: 0.1em;
  font-family: var(--fdm-font-body);
  font-weight: var(--fdm-weight-regular);
}

/* Year and title: 20/150% link */
.fdm-work__pager-link {
  max-width: 100%;
  font-size: var(--fdm-fs-20);
  line-height: var(--fdm-work-lh-20);
  overflow-wrap: break-word;
}

/* 8. Larger view (lightbox) ------------------------------------------------ */

/* A native <dialog>, built by work.js and opened with showModal(), so the
   page behind it is inert, focus stays inside and Escape closes it. */
.fdm-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: color-mix(in srgb, var(--fdm-ink) 96%, transparent);
  color: var(--fdm-on-green);
}

.fdm-lightbox[open] {
  display: flex;
  flex-direction: column;
}

.fdm-lightbox::backdrop {
  background: var(--fdm-ink);
}

.fdm-lightbox__bar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--fdm-space-16);
  padding: var(--fdm-space-12) var(--fdm-header-gutter);
}

.fdm-lightbox__title {
  min-width: 0;
  font-family: var(--fdm-font-heading);
  font-size: var(--fdm-fs-23);
  font-weight: var(--fdm-weight-semibold);
  line-height: var(--fdm-lh-23);
  overflow-wrap: break-word;
}

.fdm-lightbox__close {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--fdm-work-touch);
  height: var(--fdm-work-touch);
  margin-right: calc(var(--fdm-space-10) * -1);
  border-radius: var(--fdm-radius-control);
  color: var(--fdm-on-green);
}

.fdm-lightbox__close:hover {
  background: color-mix(in srgb, var(--fdm-on-green) 14%, transparent);
}

.fdm-lightbox__close .fdm-icon {
  width: var(--fdm-space-24);
  height: var(--fdm-space-24);
}

/* The picture fills the space that is left and is always shown whole. */
.fdm-lightbox__stage {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 var(--fdm-header-gutter) var(--fdm-space-24);
  cursor: zoom-out;
}

.fdm-lightbox__image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Stops the page behind the open dialog from scrolling. */
html.is-lightbox-open {
  overflow: hidden;
}

/* Phone and tablet: one column ---------------------------------------------- */

@media (max-width: 1023.98px) {
  .fdm-work__layout {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--fdm-space-32);
    padding-bottom: var(--fdm-space-56);
  }

  /* The picture keeps its desktop size instead of filling a tablet. */
  .fdm-work__figure {
    width: 100%;
    max-width: var(--fdm-work-image-max);
  }
}

@media (max-width: 599.98px) {
  .fdm-work__back {
    padding-block: var(--fdm-space-20) var(--fdm-space-16);
  }

  .fdm-work__layout {
    row-gap: var(--fdm-space-24);
    padding-bottom: var(--fdm-space-40);
  }

  .fdm-work__figure {
    gap: var(--fdm-space-16);
    max-width: none;
  }

  .fdm-work__picture {
    gap: var(--fdm-space-10);
  }

  .fdm-work__body {
    gap: var(--fdm-space-24);
  }

  /* Label above its value */
  .fdm-work__fact {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--fdm-space-2);
    padding-block: var(--fdm-space-12);
  }

  .fdm-work__fact dd {
    font-size: var(--fdm-fs-18);
    line-height: var(--fdm-lh-18-ui);
  }

  .fdm-work__section {
    gap: var(--fdm-space-10);
  }

  .fdm-work__heading {
    font-size: var(--fdm-fs-24);
    line-height: var(--fdm-lh-24-heading);
  }

  .fdm-work__prose {
    font-size: var(--fdm-fs-18);
    line-height: var(--fdm-lh-18);
  }

  .fdm-work__pager {
    grid-template-columns: minmax(0, 1fr);
    padding-block: var(--fdm-space-8) var(--fdm-space-48);
  }

  .fdm-work__pager-item,
  .fdm-work__pager-item--next {
    grid-column: 1;
    padding-top: var(--fdm-space-20);
  }

  .fdm-work__pager-link {
    font-size: var(--fdm-fs-18);
    line-height: var(--fdm-lh-18-ui);
  }

  .fdm-lightbox__title {
    font-size: var(--fdm-fs-19);
    line-height: var(--fdm-lh-19);
  }

  .fdm-lightbox__stage {
    padding-bottom: var(--fdm-space-16);
  }
}
