/* ================================================================
   Designed project pages (Projects/<folder>/layout.json).
   Used by the site (index.html) AND by the Site Editor, so the editor
   shows exactly what the site will show.

   The page is a stack of bands:
   - split band: a left and a right half, each its own grid of 6 columns;
   - full band:  one grid of 12 columns across the whole width
                 (a big picture or a big title).
   On phones the two halves of a split band go under each other, the right
   one (with the text) first and the left one below it, each filling the
   width; everything inside a half keeps its arrangement. A band with only
   pictures goes from left to right: the left half first.
   All sizes are measured in the width of the half (or band), so a
   layout scales as one piece.
   ================================================================ */

.lp-page {
  container-type: inline-size;
}

.lp-band {
  margin-bottom: 0;                   /* (no extra space: every block already keeps one picture gap below itself, see .lp-grid) */
}

.lp-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 2.1526cqi;              /* exactly the gap between two pictures in a half: 4.4% of a half = 0.044 / 2.044 of the page */
}

.lp-half {
  container-type: inline-size;
  min-width: 0;
}

/* Inside a half: 6 columns. 1u = 1% of the half's width. */
.lp-grid {
  --u: 1cqi;
  --lp-unit: var(--u);              /* (what the heights of the rows are measured in: layout.js linesOf) */
  --lp-gap: calc(4.4 * var(--u));   /* (roomy: layout.js GAP and the Site Editor's rowsFor use the same 4.4) */
  --lp-row: calc((100cqi - 5 * var(--lp-gap)) / 48);   /* an eighth of a column high: fine, so a section ends right under its pictures */
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  /* Between columns the picture gap; between rows none: each block has its own height plus one picture gap below it
     (layout.js linesOf works it out exactly), so pictures are exactly as far apart up and down as side to side. */
  column-gap: var(--lp-gap);
  row-gap: 0;
  grid-auto-rows: minmax(var(--lp-row), auto);
  position: relative;
}

/* Across the whole width: 12 columns, and exactly the same sizes and gaps as in a half (two halves and the gap
   between them are 204.4u wide). */
.lp-full .lp-grid {
  --u: calc(100cqi / 204.4);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  --lp-row: calc((100cqi - 11 * var(--lp-gap)) / 96);
}

.lp-block {
  position: relative;
  min-width: 0;
  min-height: 0;
}

/* Titles: the Levilingerak font, in four sizes. */
.lp-block h2 {
  margin: 0;
  font-family: "Levilingerak", "Arial Black", sans-serif;
  font-weight: normal;
  letter-spacing: -0.04em;
  line-height: 0.9;
  overflow-wrap: anywhere;
}
.lp-size-s h2  { font-size: calc(4 * var(--u)); }      /* (all a fifth smaller than before: calmer beside the texts) */
.lp-size-m h2  { font-size: calc(6.4 * var(--u)); }
.lp-size-l h2  { font-size: calc(9.6 * var(--u)); }
.lp-size-xl h2 { font-size: calc(13.6 * var(--u)); }

/* Texts: Jost, in three sizes. The normal one (M) is exactly as big as the short description at the top
   (style.css: --project-text); S is a bit smaller, L a bit bigger. Their titles are smaller than a title on its
   own, and always clearly bigger than the words. */
.lp-text-body p {
  margin: 0 0 1em;
  line-height: 1.5;
  white-space: pre-line;      /* (a single Enter is a new line, as in the Site Editor) */
}
.lp-text-body p:last-child { margin-bottom: 0; }
.lp-text.lp-size-s { --words: calc(0.85 * var(--project-text, 1.45rem)); --title: 4; }
.lp-text.lp-size-m { --words: var(--project-text, 1.45rem); --title: 5.2; }
.lp-text.lp-size-l { --words: calc(1.2 * var(--project-text, 1.45rem)); --title: 6.4; }
.lp-text-body { font-size: var(--words); }
.lp-text h2 { font-size: max(var(--title) * var(--u), 1.4 * var(--words)); }
.lp-text h2 {                         /* (in Jost like its words, a bit heavier; a title on its own keeps the Levilingerak font) */
  margin-bottom: calc(2.6 * var(--u));
  font-family: "Jost", "Avenir Next", "Segoe UI", Arial, sans-serif;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

/* A picture always keeps its proportion (square, 4:3, 3:4, 16:9 or 9:16): its height comes from its
   width, and the photo fills it exactly. The rows it spans only reserve the room for it. */
.lp-picture[style*="--ratio"] {
  align-self: start;
  aspect-ratio: var(--ratio);
}

.lp-picture img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lp-picture.is-empty {
  background: repeating-linear-gradient(45deg, rgba(31, 24, 19, 0.06) 0 10px, rgba(31, 24, 19, 0.02) 10px 20px);
}

/* Phones: the two halves of a split band under each other, from right to left: first the right one (the text),
   then the left one (its pictures). The top of the page does the same (style.css .detail-top-picture).
   With only pictures (layout.js: lp-only-pictures) from left to right. */
@media (max-width: 760px) {
  .lp-split {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0;   /* (each half already ends with one picture gap) */
  }

  .lp-split:not(.lp-only-pictures) > .lp-side-right {
    order: -1;
  }

  /* A full-width picture is as wide as the others here, so the gap under it is too (the grid itself has 2.15%). */
  .lp-full {
    margin-bottom: 2.2474cqi;
  }
}

/* ---- Texts: a title and its words in one block ----
   The block is sized in the Site Editor; like a picture it keeps one picture gap free below itself. The words line
   up with the left side of the pictures, keep some room on their right, and start a little below the top of the
   block. With more words than room the rows grow, so nothing is ever cut off. Every text is the same, wherever it
   stands on the page. */
.lp-text {
  box-sizing: border-box;
  margin-bottom: calc(var(--lp-gap) - 1.7 * var(--u));   /* (one row less: a text that just fits its rows also fits beside the exact height of its pictures) */
  padding: calc(3.4 * var(--u)) 9% 0 0;
}

.lp-text-body {
  max-width: 36em;                  /* (a comfortable reading width, also in a wide block) */
}

/* A title on its own: the same left side and room on its right, and as much lower at the top of any section. */
.lp-title {
  padding-bottom: 3.2cqi;
}

.lp-split .lp-title { padding-right: 9%; }
.lp-title.lp-top-row { padding-top: calc(3.4 * var(--u)); }

/* In the right half the texts keep more room from the pictures on their left (the title and description at the top
   keep the same: style.css .detail-top-text), and less on their right, so their lines stay as long. */
@media (min-width: 761px) {
  .lp-split .lp-side-right :is(.lp-title, .lp-text) {
    padding-left: 5cqi;
    padding-right: 4cqi;
  }
}

/* Phones: the halves are under each other, so a half with only texts is as high as its words. */
@media (max-width: 760px) {
  .lp-split :is(.lp-title, .lp-text) {       /* (a bit narrower than the pictures: style.css --text-inset) */
    padding-left: var(--text-inset, 0px);
    padding-right: var(--text-inset, 0px);
  }

  .lp-text {                                 /* (and a little more room above and below the words) */
    padding-top: calc(3.4 * var(--u) + 6px);
    margin-bottom: calc(var(--lp-gap) + 20px);   /* (the least room between the words and the picture under them) */
  }

  .lp-split .lp-grid.lp-only-texts { --lp-row: 0px; --lp-unit: 0px; }
  .lp-text.is-blank { padding: 0; margin: 0; }
}
