/* ============================================================================
   layout.css — POSITION AND SIZE ONLY
   ----------------------------------------------------------------------------
   No colour. No font-size. No font-weight. No border-radius. guard.sh fails
   the build if any of those appear here.

   EVERY INNER PAGE USES ONE 4-COLUMN GRID.

   The previous version positioned boxes absolutely, sizing them by viewport
   WIDTH while placing rows by viewport HEIGHT. On the square design ratio that
   looked right; on every real screen the rows sat closer together than the
   boxes were tall, so they overlapped — 116px on the Referenzen gallery and
   107px on the two Über uns portraits, at 19 of 35 tested sizes.

   Now one square --cell drives both axes and the grid places things in cells.
   Overlap is impossible by construction, not by arithmetic that happened to
   work at one aspect ratio.

   The grid mirrors the InDesign layout:

       col      1        2        3        4
       row 1  [ panel or tiles ][ images or panel ]
       row 2  [ panel or tiles ][ images or panel ]
       row 3  [  four cells across the full width  ]
   ========================================================================== */

.screen {
  position: fixed;
  inset: 0;
  display: block;
}

/* ---- header ------------------------------------------------------------ */
/* THE HEADER'S CONTENTS SIT ON THE CONTENT COLUMN.
   The bar itself still runs edge to edge - that is what the document draws,
   a full-width band - but everything inside it is confined to the same
   four-cells-and-three-gaps box the page's content uses, and the nav is
   pushed to that box's right edge. In the document the last word, "Kontakt",
   ends at x 1520.0 and the column ends at x 1520.0. */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  display: grid;
  grid-template-columns: var(--content-w);
  justify-content: center;
  align-items: center;
  z-index: var(--z-header);
}
.site-header .nav { justify-self: end; }

/* The logo deliberately overhangs the header band onto the page below it.
   Measured from PDF page 1: x 12.0%, y 0.9%, height 16%. */
/* THE LOGO'S LEFT EDGE IS THE CONTENT COLUMN'S LEFT EDGE.
   In the document the mark starts at x 209.8 and the column at x 180, so it
   is inset by about 30 units - but the guides make plain that it is meant to
   sit on the column and Fawad read it the same way: "in design the logo is
   not exactly to the left corner. but i think that is a mistake, we should
   make it like that." So it is flush.

   It still overhangs the band downwards, which IS deliberate: 160 units of
   header against a 260.9-unit mark. */
.brand {
  position: fixed;
  top: var(--logo-y);
  left: calc(50% - var(--content-w) / 2);
  height: var(--logo-h);
  z-index: calc(var(--z-header) + 1);
}
.brand img { height: 100%; width: auto; }

/* WALTER. Absolutely placed inside .brand, so he is out of the flow and the
   link stays exactly as wide as the logo: left 100% is the logo's right edge.
   Sizes come from tokens.css (--mascot-*), measured off the 19 Oct PDF.

   The three custom properties are the client's sliders, printed by the
   renderer as plain numbers (percent). The fallbacks ARE the layout, so a page
   saved before the sliders existed draws him exactly where the PDF does.
   Offsets are in units of his own box, so +100 moves him one Walter over.

   `.brand .brand__mascot`, not `.brand__mascot`: `.brand img` above would
   otherwise win and stretch him to the logo's full height. max-width: none
   because elements.css caps every img at its parent's width - here that is
   the logo, and at 150% he is wider than it. pointer-events: none so he never
   swallows a click meant for the page he overhangs. */
.brand .brand__mascot {
  position: absolute;
  left: calc(100% + var(--mascot-gap) + var(--mascot-box) * var(--mascot-x, 0) / 100);
  top: calc(var(--mascot-top) + var(--mascot-box) * var(--mascot-y, 0) / 100);
  width: calc(var(--mascot-box) * var(--mascot-size, 100) / 100);
  height: auto;
  max-width: none;
  pointer-events: none;
}

/* gap must NOT be a percentage here: .nav is an auto-width flex item, so a
   percentage gap resolves against a width that is itself being computed from
   the content, and the row ends up wider than its own box. */
.nav {
  display: flex;
  gap: 1.15em;
  align-items: center;
  min-width: 0;
}

/* ---- full-bleed background -------------------------------------------- */
.bg {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-bg);
  overflow: hidden;
}
.bg img { width: 100%; height: 100%; object-fit: cover; }
/* The scrim, as a pseudo-element so no template changes and the two renderers
   stay byte-identical. .bg exists only on the four inner screens — the start
   screen has .cards instead — which is exactly where the document draws it. */
.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ---- start: the card grid ---------------------------------------------
   Column count comes from --card-count, never a hardcoded 4. */
.cards {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(var(--card-count, 4), 1fr);
  z-index: var(--z-cards);
}
.card {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.card__img { position: absolute; inset: 0; }

/* WHERE EACH CARD LOOKS INTO ITS PHOTO.
   All four sources are landscape (about 3:2) and every card is a tall narrow
   slot, so `cover` throws away most of the width. Centred, card 1 landed on a
   corrugated wall and the white logo sitting over it became unreadable; the
   design shows a flat blue machine door there instead.

   These four numbers are not taste. They are the InDesign crop windows,
   read out of the IDML: for each card, (frameLeft - imageLeft) / (imageWidth
   - frameWidth). object-position uses exactly that ratio, so the same part of
   each photo shows even though the browser's slot is a different shape from
   the 426x1542 one in the document.

   Vertical is centred on purpose. The document leaves only 3 to 47px of
   vertical overflow, which is noise, so its vertical figure carries no
   information to copy.

   EXCEPT ÜBER UNS, FROM 26 OCT. The client swapped its photo for their own
   flatbed printer ("Hintergrund Maschine.jpg"), which the IDML has never seen,
   so there is no crop window to read. 70% chosen by looking at 0/25/50/70:
   it shows the roll holder, which says "printing" at a glance, and puts a
   dark picture frame under the logo where the old door was - the lighter
   crops put the white logo lettering on a pale wall. */
.card[data-target="ueber-uns"]  .card__img { object-position: 70% 50%; }
.card[data-target="portfolio"]  .card__img { object-position: 81% 50%; }
.card[data-target="referenzen"] .card__img { object-position: 36% 50%; }
.card[data-target="kontakt"]    .card__img { object-position: 52% 50%; }

/* The band sits at a fixed slice of the card, and the label sits inside it. */
.card__veil {
  left: 0;
  right: 0;
  top: var(--band-top);
  height: var(--band-h);
}
.card__label {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--label-mid);
  translate: 0 -50%;
  z-index: 1;
  padding: 0 6%;
}

@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(var(--card-count, 4), 1fr);
    /* THE CARDS RUN ALL THE WAY DOWN, AND THE ARROW SITS ON THE PHOTOGRAPH.
       They were stopped short at --footer-peek + --arrow-fh to keep the last
       card clear of the dock. That solved one problem and made a worse one:
       the strip under the cards is the page's flat near-black, the accent on
       Start and Kontakt is that same near-black, and the arrow vanished into
       it completely. Fawad: "where the fuck is the arrow of footer. how the
       fuck will someone know where to click." The document puts the arrow over
       the picture, which is what gives its silhouette an edge.

       What made the overlap ugly the first time was the footer's peeking
       "Kontakt" text stacked on the Kontakt card's own label. The peek is 8px
       now — a colour strip with no text in it — so there is nothing to clash. */
    bottom: 0;
  }
  /* THE WHOLE CARD IS VEILED, NOT A BAND ACROSS ITS MIDDLE.
     Fawad: "in mobile, the start page is really messy... it is too much of the
     background image and you can barely read anything." On the desktop each
     card is a tall narrow slot and a band is enough. On a phone the card is a
     wide shallow strip, the photograph fills it, and one word of white type
     has to survive on top of whatever happens to be behind it. */
  .card__veil { top: 0; height: 100%; }
}

/* ============================================================================
   THE CONTENT GRID
   ========================================================================== */

.grid {
  position: absolute;
  top: var(--grid-top);
  left: 50%;
  translate: -50% 0;
  display: grid;
  grid-template-columns: repeat(4, var(--cell));
  grid-auto-rows: var(--cell);
  gap: var(--gap);
  z-index: var(--z-content);
}

/* The text panel is two cells wide and two tall, exactly as drawn, so it lines
   up with the images beside it instead of growing and pushing things apart. */
.panel {
  padding: var(--panel-pad-y) var(--panel-pad-x);
  /* CENTRED, NOT TOP-ALIGNED. The document centres every panel's text frame
     in its box - the space above and below is equal on all three pages that
     have one. Ours sat at the top with 11.85% above and 30.54% below.
     `safe` so that text taller than the box still starts at the top and stays
     reachable instead of overflowing off both ends. */
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  overflow-y: auto;             /* last resort, this panel only */
  overscroll-behavior: contain;
  min-width: 0;
  min-height: 0;
}
.panel > * + * { margin-top: 0.85em; }

.grid--referenzen .panel { grid-area: 1 / 1 / 3 / 3; }

/* Über uns and Kontakt have nothing in the bottom-left cells, so the panel
   takes all three rows. The CVs are 300 words and on a 900px screen two rows
   is 397px - the text overflowed and the panel grew a scrollbar. Using the
   empty space is free height and matches the drawing, which also leaves that
   corner blank. */
.grid--ueber-uns .panel,
.grid--kontakt .panel {
  grid-area: 1 / 1 / 4 / 3;
  align-self: start;
  height: auto;                                              /* hug the text */
  min-height: calc(2 * var(--cell) + var(--gap));            /* as drawn      */
  max-height: calc(3 * var(--cell) + 2 * var(--gap));        /* before scroll */
}

.grid--portfolio .panel { grid-area: 1 / 3 / 3 / 5; }

/* ---- über uns ---------------------------------------------------------- */
.person {
  position: relative;
  grid-column: 3;
  min-width: 0;
  min-height: 0;
}
/* Rows 2 and 3, not 1 and 2. In the document the photo's BOTTOM edge lines up
   with the bottom of the text panel beside it (both at 58.0% and 58.3% of the
   page), and the name box sits in the row under that. Placed in rows 1 and 2
   the photo sat level with the TOP of the panel instead and the whole right
   column read as floating. */
.person--top    { grid-row: 2; }
.person--bottom { grid-row: 3; }

/* The photo and the name box OVERLAY each other and cross-fade; they must not
   stack in flow, or .person grows to the sum of both. */
.person__frame,
.person__box {
  position: absolute;
  inset: 0;
}
.person__photo { width: 100%; height: 100%; }
.person__box {
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* same trap as .tile */
  align-content: center;
  gap: 0.5em;
  padding: 6%;
}

/* The arrow rides the BORDER of the box: along the top, down the far side and
   back along the bottom. Sized in viewport units because a percentage here
   resolves against .person, not the page. */
.person__arrow {
  position: absolute;
  width: var(--arrow-pw);
  height: var(--arrow-ph);
  pointer-events: none;
  z-index: 2;
}

/* ---- portfolio --------------------------------------------------------- */
.tile {
  position: relative;
  display: grid;
  /* NOT place-content:center, and NOT justify-items:center either.
     Both stop the text box from stretching, so it takes its max-content width
     and a long German compound pushes straight out of the tile. Measured at
     1024x768 with the caps applied: the content box was 125px wide and the
     widest line was 194px, because a centred grid item is sized to its
     content, not to its track.
     The item must STRETCH (the default) and the TEXT is centred inside it by
     text-align, which is what elements.css already does. align-content still
     centres the block vertically. */
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  /* THE CHEVRON HANGS INTO THE GAP; IT DOES NOT EAT THE TILE.
     In the document the chevron is a separate polygon sitting in the gutter
     between two columns, so the text frame keeps the tile's full 299 units.
     Folding it into the tile's own clip-path (done to stop it registering as
     eight false text overflows) also took its width off the text, which left
     roughly 9.6 characters per line where the document has 14. Once the text
     was set in capitals that difference clipped four of the eight tiles.
     So the box is one cell PLUS the chevron, and the chevron half is padding:
     the flat body is exactly one cell wide again. */
  width: calc(100% + var(--notch));
  /* The document insets the text 3.2% of the tile in total, so 2% a side is
     already generous; 6% a side cost two lines of height. */
  padding: 2% calc(var(--notch) + 2%) 2% 2%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  /* THE ARROW SITS ON THE TOP CORNER; THE TILE STAYS A RECTANGLE.
     Measured from the IDML, portfolio page, every one of the eight tiles:
       tile     300 x 300 units, a plain rectangle
       arrow    three points - (tileRight, tileTop), (tileRight, tileTop+81.5),
                (tileRight+40.7, tileTop+40.7)
     So the triangle hangs off the TOP right corner, is 27% of the tile tall,
     and its tip reaches 13.6% of the tile out into the gutter. --notch is that
     40.7, so the arrow is --notch out and 2 x --notch tall.

     WHAT WAS WRONG. We tapered the tile's WHOLE right edge to a point at half
     its height, which turns a 300-unit square into an arrowhead 300 units
     tall. The drawing has a square with a small flag on one corner. Fawad, 5
     Sep: "portfolio page is different. in those cards there is an arrow and we
     have made it different." */
  clip-path: polygon(
    0 0,
    calc(100% - var(--notch)) 0,
    100% var(--notch),
    calc(100% - var(--notch)) calc(var(--notch) * 2),
    calc(100% - var(--notch)) 100%,
    0 100%
  );
}
/* two in row 1, two in row 2, four across row 3 — as drawn */
.grid--portfolio .tile:nth-of-type(1) { grid-area: 1 / 1; }
.grid--portfolio .tile:nth-of-type(2) { grid-area: 1 / 2; }
.grid--portfolio .tile:nth-of-type(3) { grid-area: 2 / 1; }
.grid--portfolio .tile:nth-of-type(4) { grid-area: 2 / 2; }
.grid--portfolio .tile:nth-of-type(5) { grid-area: 3 / 1; }
.grid--portfolio .tile:nth-of-type(6) { grid-area: 3 / 2; }
.grid--portfolio .tile:nth-of-type(7) { grid-area: 3 / 3; }
.grid--portfolio .tile:nth-of-type(8) { grid-area: 3 / 4; }

/* The error page. One panel where the Referenzen panel sits, so it reads as a
   page of this site rather than as a server message. No background photograph
   and no gallery, so nothing competes with it.

   TWO CELLS WIDE, AND ONLY AS TALL AS ITS THREE LINES. Spanning two rows like
   the real panels do left 225px of empty colour under the text and the page
   looked unfinished. `align-self: start` stops the item stretching down its
   track; the width still stretches across both columns, which is what keeps
   the line length the same as every other panel on the site. */
.grid--fehler .panel {
  grid-area: 1 / 1 / 2 / 3;
  align-self: start;
  height: auto;
}

/* ---- referenzen -------------------------------------------------------- */
.slides {
  grid-area: 1 / 1 / 4 / 5;
  display: grid;
  grid-template-columns: repeat(4, var(--cell));
  grid-auto-rows: var(--cell);
  gap: var(--gap);
  min-width: 0;
  min-height: 0;
}
.slide {
  grid-area: 1 / 1 / 4 / 5;
  display: grid;
  grid-template-columns: repeat(4, var(--cell));
  grid-auto-rows: var(--cell);
  gap: var(--gap);
}
.shot-wrap { min-width: 0; min-height: 0; }
/* cells 1-2 of rows 1-2 stay empty: the panel sits there */
.slide .shot-wrap:nth-child(1) { grid-area: 1 / 3; }
.slide .shot-wrap:nth-child(2) { grid-area: 1 / 4; }
.slide .shot-wrap:nth-child(3) { grid-area: 2 / 3; }
.slide .shot-wrap:nth-child(4) { grid-area: 2 / 4; }
.slide .shot-wrap:nth-child(5) { grid-area: 3 / 1; }
.slide .shot-wrap:nth-child(6) { grid-area: 3 / 2; }
.slide .shot-wrap:nth-child(7) { grid-area: 3 / 3; }
.slide .shot-wrap:nth-child(8) { grid-area: 3 / 4; }

.dots {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  top: calc(var(--grid-top) + 3 * var(--cell) + 2 * var(--gap) + 1.6vh);
  display: flex;
  gap: 1.1vh;
  z-index: var(--z-content);
}
.dot { width: 1.1vh; height: 1.1vh; min-width: 10px; min-height: 10px; }

/* ---- kontakt ----------------------------------------------------------- */
.map {
  grid-area: 1 / 3 / 3 / 5;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
/* THE MAP IS SHOWN WHOLE, NOT CROPPED.
   The frame is square — 637x637 in the document, Spreads/Spread_u34a5 — and
   the client's map is 1600x740. `cover` cropped it to a 740px square, and a
   740px picture in this box is soft: Fawad, "the image quality is really
   really bad." `contain` puts all 1600px of it across a ~400px box instead,
   which is four times the pixels it needs, and keeps their own artwork whole:
   the /// label, the detail inset and the pin. Fawad: "put back their own
   image. they had much better things." */
/* THE MAP FILLS THE SQUARE.
   The frame is square — 637x637 in the document, Spreads/Spread_u34a5 — and
   tools/build-map.mjs now draws the map SQUARE at 1600x1600, so cover has
   nothing to throw away. `left` stays as the anchor because it is the right
   answer for any wide map that might be dropped in later: everything that
   says anything sits on the left of this picture — the ///huhn.ziegen.klappe
   label top-left, the close-up of the yard bottom-left. Fawad: "make the
   cover the box and also should show the left side. that is where the whole
   fucking content is." */
.map img { width: 100%; height: 100%; object-fit: cover; object-position: left center; }
.map__links {
  grid-area: 3 / 3 / 4 / 5;
  display: flex;
  gap: 5%;
  align-items: flex-start;
  align-content: flex-start;
  flex-wrap: wrap;
}

/* ============================================================================
   MOBILE — the square design has no mobile layout, so this is new work.
   One column, everything in flow, the page scrolls. A fixed one-screen layout
   cannot hold a 300-word CV on a 390px phone.
   ========================================================================== */
@media (max-width: 768px) {
  /* elements.css sets height:100% + overflow:hidden for the one-screen desktop
     layout. Leaving height:100% here does NOT give the page back: the document
     stays 844px tall and BODY becomes the scroller instead of the window.
     Measured at 390x844 — window.scrollTo(0, 2000) left scrollY at 0 while
     body.scrollTop moved, so 2451px of the Portfolio page was reachable only
     by a scroller that iOS will not drive, and the address bar never
     collapses. height:auto hands the scroll back to the window. */
  html, body { height: auto; min-height: 100%; overflow: visible; }
  .screen { position: static; min-height: 100svh; }

  /* THE START SCREEN IS THE ONE PAGE THAT MUST NOT SCROLL.
     Fawad: "the start page in mobile should not have any scroll. but right now
     even the page doesnt scroll. there is scroll bar which is making the logo
     go small."

     Both halves of that are the same bug. 100vh on a phone is the LARGE
     viewport — the height with the address bar hidden — so a page that is
     exactly one screen tall is still taller than what you can see while the
     bar is showing. That buys a few pixels of scroll: not enough to move
     anything, but enough to fire the scroll handler and shrink the logo.

     100svh is the SMALL viewport, the height with the bars showing, so the
     document never exceeds the visible area and there is nothing to scroll.
     The lock is belt and braces, and it is scoped to the start screen by an
     attribute main.js puts on <html> — locking every page here is what once
     made 2451px of Portfolio unreachable. */
  html[data-screen="start"],
  html[data-screen="start"] body { height: 100%; overflow: hidden; }
  html[data-screen="start"] .screen { min-height: 0; height: 100svh; }

  .grid {
    position: static;
    translate: none;
    display: block;
    /* The bottom was a flat 16vh and it did not match the top. Measured on a
       390px screen: 25px of air above the first tile and 169px of nothing
       below the last one. The bottom only has to do two jobs — leave the same
       3vh of air as the top, and clear the footer arrow — so it is written as
       exactly those two things instead of one round number. */
    /* Clears the LOGO, not just the header bar. The mark overhangs the bar
       deliberately, and at its new mobile size it is taller than the bar, so
       clearing only --header-h left it sitting on top of the first tiles. */
    padding:
      calc(var(--logo-y) + var(--logo-h) + 3vh)
      6%
      calc(3vh + var(--footer-peek) + var(--arrow-fh));
  }
  /* Panels carry 4vh below them to separate one block from the next. The last
     block has no next, and that stray 34px was most of what made the bottom
     look so much deeper than the top. */
  .grid > :last-child { margin-bottom: 0; }

  .panel,
  .grid--portfolio .panel,
  .grid--ueber-uns .panel,
  .grid--referenzen .panel,
  .grid--kontakt .panel {
    grid-area: auto;
    width: 100%;
    max-height: none;
    overflow: visible;
    margin-bottom: 4vh;
  }

  .person {
    grid-area: auto;
    width: 60%;
    aspect-ratio: 1;
    margin: 0 0 4vh;
  }

  /* .slides is the STACK, .slide is the grid of photographs. Giving both two
     columns put the three slides side by side, so the visible one was 160px
     wide inside a 343px page and its eight photographs were 78px each, with
     the two invisible slides holding open the rest of the screen. They are
     only invisible, not gone: on the desktop they are stacked absolutely, and
     turning that off here left them in the flow. */
  /* .slides is the STACK, .slide is the grid of photographs. Giving both two
     columns put the three slides side by side: the one on show was 160px wide
     inside a 343px page, its eight photographs were 78px each, and the two
     invisible ones held open the rest of the screen. They are only invisible,
     not gone — on the desktop they are stacked absolutely, and turning that
     off here left them in the flow.
     .slides stays a BLOCK. Making it a one-cell grid and overlapping the
     slides in it looked tidier and collapsed every row to 60px: .shot-wrap
     takes its height from aspect-ratio, aspect-ratio takes it from the
     resolved width, and nesting a grid in a grid row that is itself sized by
     that content closes the loop. A block parent gives the width outright. */
  .slides {
    grid-area: auto;
    position: static;
    display: block;
  }
  .slide {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: auto;
    gap: 3vw;
  }
  /* The cross-fade needs the slides to overlap and here they do not, so a
     hidden slide has to leave the flow outright or it reserves a screenful of
     nothing. The one on show still fades in. Every slide holds the same eight
     photographs, so the page height does not move when they change — measured
     below in the sweep, and worth re-measuring if the gallery ever stops
     dividing by eight. */
  .slide[aria-hidden="true"] { display: none; }
  /* Two columns for the tiles, the same as the gallery above. One per row
     made each tile a 355px square holding seven short lines and stretched the
     page to 3494px — eight screens of scrolling for one list. */
  .grid--portfolio {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* The desktop .grid sets grid-auto-rows to --cell. Turning the grid back
       on here brings that with it, and --cell is 60px on a 390px phone, so
       every row was 60px tall under a 135px tile and each one overlapped the
       row below by 75px. Rows here size to their content. */
    grid-auto-rows: auto;
    /* vw, not %, so it is directly comparable with --notch. A percentage gap
       resolves against the grid's own width and the chevron does not, so the
       chevron overhung the gutter by 2-3px and every pair of tiles in a row
       overlapped. Same class of bug as the duplicate percentage --gap. */
    gap: 3vw;
    align-content: start;
  }
  /* THE TEXT COMES FIRST ON A PHONE. The renderer emits the eight tiles and
     then the panel, which is right for the desktop grid where the panel is
     placed top-right by grid-area. Here the grid is a plain two-column flow,
     so source order wins and the visitor met eight lists of services before
     being told what the page was. Fawad: "the big box with text has to be up
     and the small boxes under." */
  .grid--portfolio .panel { grid-column: 1 / -1; order: -1; margin-bottom: 3vh; }
  .grid--portfolio .tile:nth-of-type(n) { grid-area: auto; }
  .slide .shot-wrap:nth-child(n) { grid-area: auto; }
  /* The gallery keeps its square: those are photographs and the shape is the
     point. The tiles do NOT. aspect-ratio on an item that is stretched to its
     track width is circular — the track sizes itself from the text's own
     height, the item then claims a square from the resolved width, and the
     row is left 70px tall holding a 178px box. Measured: every tile overlapped
     the one below it by 108px. The tiles hold wildly different amounts of
     text anyway, so on a phone they simply take the height they need. */
  .shot-wrap { aspect-ratio: 1; }
  .tile { min-height: 9rem; }

  /* The dots are a child of .screen, NOT of .grid — so the grid's 16vh bottom
     padding lands BETWEEN the gallery and them. Measured on a 390px screen:
     the gallery ended at 1161 and the dots sat at 1322, adrift 161px below it
     at the very end of the page, which is why they read as missing. The grid
     gives back its bottom padding here and the dots' own margin below carries
     the clearance from the fixed footer arrow instead. */
  .grid--referenzen { padding-bottom: 2vh; }
  /* They are also a child of .screen rather than .grid, so nothing else was
     keeping them clear of the arrow. */
  .dots {
    /* RELATIVE, NOT STATIC. This said `static`, and z-index does nothing at
       all on a static element — so the .dots kept their z-index: 20 in the
       computed style and were painted UNDERNEATH .bg, which is a fixed
       photograph at z-index 0 covering the whole viewport. They were the
       right size, in the right place, with the right colours, and completely
       invisible; document.elementFromPoint on the middle of the strip
       returned the background IMG. Two rounds of "the dots are missing on
       mobile" were this. `relative` changes nothing about the layout and
       makes the z-index real. */
    position: relative;
    /* left AND top back to auto. The desktop rule pins the strip with
       `position:absolute; left:50%; top:...` and cancels the half with
       `translate:-50% 0`. This block used to say `position:static`, which
       ignores left and top outright, so dropping the translate was harmless.
       `relative` HONOURS them: left:50% shoved the strip half the page to the
       right and the sweep caught it at three sizes — "OFFSCREEN dots
       right@563" on a 390px screen. Turning z-index on meant turning these
       off too. */
    left: auto;
    top: auto;
    translate: none;
    justify-content: center;
    align-items: flex-start;
    margin-top: 3vh;
    /* PADDING, NOT MARGIN. This was margin-bottom, and a bottom margin on the
       LAST child collapses straight out through .screen and body: it reserved
       nothing at all, the page ended level with the dots, and scrolling to the
       bottom parked them exactly under the fixed footer's arrow. Measured at
       390x844: dots at y 799..829, handle at 795..830 — the same strip.
       Padding is part of the element's own box and cannot collapse. */
    padding-bottom: calc(3vh + var(--footer-peek) + var(--arrow-fh));
    /* THE GAP IS BETWEEN THE PAINTED DOTS, NOT BETWEEN THE TAP TARGETS.
       Each button is 30px so a thumb can hit it, but only the middle 10px is
       painted — so a 4vw gap put 20px of padding PLUS 16px of gap between two
       10px dots, about 36px of air. Fawad: "they are huge and have from
       feeling like 100 px gap between them." The desktop draws 10px dots with
       10px between them; a negative margin pulls the buttons together to the
       same reading without shrinking anything a thumb has to hit. */
    gap: 0;
  }
  /* A 10px target is too small for a thumb. The button grows to 30px and the
     dot stays 10px, because the padding is transparent and the background is
     clipped to the content box. Nothing looks different; it is just tappable. */
  .dot {
    width: 30px;
    height: 30px;
    padding: 10px;
    margin: 0 -5px;   /* 20px of padding minus 10px of overlap = a 10px gap */
    background-clip: content-box;
  }

  .map { grid-area: auto; width: 100%; aspect-ratio: 1; margin-bottom: 2vh; }
  /* The two links under the map are the last thing on the page and the footer
     is fixed over the bottom of it, so they need the same clearance the grid
     and the dots give themselves. They were 41px above the closed footer. */
  .map__links { margin-top: 1vh; }

  /* HORIZONTAL DRAGS BELONG TO THE GALLERY, VERTICAL ONES TO THE PAGE.
     The swipe in slider.js listens for pointer events, and without this the
     browser owns every gesture on a scrolling page: it decides a sideways drag
     is the start of a scroll, fires pointercancel, and the swipe never
     completes. pan-y says "you keep the up and down, I take the sideways".
     Fawad: "the swipe left and right doesnt work in mobile. i cant do shit." */
  .slides { touch-action: pan-y; }
  .map__links { grid-area: auto; }
}

/* ---- footer -----------------------------------------------------------
   The dock has ZERO height so its bottom edge is the viewport's bottom edge.
   The footer starts below the fold; only the handle is on screen when closed. */
.footer-dock {
  position: fixed;
  left: var(--footer-x);
  width: var(--footer-w);
  bottom: 0;
  height: 0;
  z-index: var(--z-footer);
}
/* THE HANDLE IS A CHILD OF THE PANEL AND SITS ON ITS TOP EDGE.
   It used to be a sibling pinned to the dock: `bottom: var(--footer-peek)`
   when closed and `bottom: var(--footer-h)` when open. Both are arithmetic on
   a TOKEN, and on a phone .footer is `height: auto` and measures 231px against
   a token that says 212 - so the open position put the arrow 19px BELOW the
   panel's real top edge and the panel painted straight over it. Fawad: "when i
   click on kontakt to come up, the arrow kind of goes behind the box that is
   coming up."

   `bottom: 100%` on a child means "directly above my parent's top edge",
   whatever that edge happens to be, and the handle now travels with the panel
   because it IS the panel. No token, no open/closed rule, nothing to keep in
   step. */
.footer__handle {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  bottom: 100%;
  width: var(--arrow-fw);
  height: var(--arrow-fh);
  z-index: 1;
}
.footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--footer-h);
  padding: 3.2vh 6% 2vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.4vh;
}
/* 4.47%, not 6%: the document puts exactly 19 units between the words in a
   425-unit footer. At 6% the four of them could not share one line. wrap stays
   as a safety net — if a translation ever makes a word longer, it drops to a
   second line rather than spilling out of the box. */
.footer__links { display: flex; gap: 4.47%; flex-wrap: wrap; }
.footer__body { display: flex; align-items: flex-end; justify-content: space-between; gap: 4%; }
.footer__socials { display: flex; gap: 12%; align-items: center; }

@media (max-width: 768px) {
  .footer { height: auto; padding: 3vh 6% 2.4vh; }
}

/* ============================================================================
   MOBILE NAVIGATION — hamburger, full-screen sheet, and a logo that shrinks
   ----------------------------------------------------------------------------
   Fawad, 5 Sep: "we should do Hamburger menu in mobile and the logo needs to
   be much bigger than current version and it should become smaller when
   someone scrolls down. and hamburger menu should be full screen cover."

   The square design has no mobile layout, so all of this is new work rather
   than a measurement. What IS carried over is that five German nav words never
   did fit a 390px bar — that is why --fs-nav had a floor lower than the body
   text, which was a symptom of this missing menu all along.
   ========================================================================== */

/* The button does not exist on the desktop; the row of links does. */
.nav__burger { display: none; }
.menu { display: none; }

@media (max-width: 768px) {
  .nav { display: none; }

  .nav__burger {
    display: grid;
    align-content: center;
    gap: 5px;
    width: 44px;                 /* a thumb-sized target, not an icon-sized one */
    height: 44px;
    padding: 0 8px;
    margin-left: auto;
    z-index: calc(var(--z-header) + 2);
  }
  .nav__burger-bar { display: block; height: 2px; width: 100%; }

  /* THE SHEET. Fixed to the viewport and inset 0, so it covers everything
     including the header bar it was opened from — "full screen cover". */
  .menu {
    position: fixed;
    inset: 0;
    z-index: var(--z-menu);
    /* CLOSED IS THE DEFAULT. Writing display:grid here overrode both the
       [hidden] attribute the renderer ships and the display:none above, so
       the sheet was open on every mobile page load. Only the open state
       may set a display. */
    display: none;
    align-content: center;
    justify-items: center;
    gap: 4vh;
    padding: 12vh 8% calc(6vh + var(--footer-peek) + var(--arrow-fh));
  }
  html[data-menu="open"] .menu { display: grid; }
  /* THE BUTTON HAS TO STAY REACHABLE. .site-header carries a z-index, so it
     opens a stacking context and nothing inside it can climb above the sheet
     however high its own z-index goes — the burger was buried and the only
     ways out were Escape or picking a link. Raising the header itself (and
     the logo, which is a separate element) puts the bar and its X back on
     top, which is where a phone expects the close control to be. */
  html[data-menu="open"] .site-header { z-index: calc(var(--z-menu) + 1); }
  html[data-menu="open"] .brand { z-index: calc(var(--z-menu) + 2); }
  /* Nothing behind the sheet should scroll while it is open. */
  html[data-menu="open"] body { overflow: hidden; }

  /* The state lives on <html>, not on the header: .brand is emitted BEFORE
     .site-header, so a sibling combinator from the header cannot reach it.

     SCALE, NOT HEIGHT. Animating height re-runs layout every frame, and this
     one fires on SCROLL on a PHONE — the weakest CPU and the place jank shows
     most. scale is a compositor property, so the shrink costs no layout at
     all, and the logo is position:fixed so nothing reflows around it either
     way. transform-origin keeps it anchored to the corner it already sits in.
     (translate is a separate property here and still applies; the individual
     transform properties compose translate, then rotate, then scale.) */
  .brand {
    /* ON THE PAGE'S OWN GUTTER, not the desktop content column.
       .brand takes `left: calc(50% - var(--content-w) / 2)` from the desktop
       rule, and --content-w is four square cells and three gaps — a desktop
       measurement that means nothing on a phone, where the grid is one column
       inset 6%. Same principle as the desktop, applied to this layout: the
       logo starts where the content starts. */
    left: 6%;
    transform-origin: top left;
    /* scale: 1 explicitly. Its initial value is the keyword `none`, not the
       number 1, and a transition from a keyword has nothing to interpolate —
       measured, the logo was a whole step behind: scrolled down it still read
       scale 1, and back at the top it read 0.44. Same reason translate is
       written out as two lengths rather than left to default to `none`. */
    scale: 1;
    translate: 0 0;
    transition:
      scale var(--dur-footer) var(--ease-out),
      translate var(--dur-footer) var(--ease-out);
  }
  /* THE HORIZONTAL HALF OF THIS TRANSLATE IS GONE, AND MUST STAY GONE.
     It read `translate: -50% var(--logo-scrolled-y)`, which was correct while
     .brand's base rule carried `translate: -50% 0` — the mark was positioned by
     its centre and the scrolled state simply repeated the offset. 1.1.11 moved
     the logo onto the content column and dropped that base translate, and this
     line was not updated: scrolling then shifted the mark half its own width to
     the left for no reason. Measured at 390px: left 34 at the top, left -19
     once scrolled, 19px of it off the side of the screen. Fawad: "the logo on
     scroll goes to the left side outside of the the screen."
     Only the vertical drop belongs here; see --logo-scrolled-y. */
  html[data-scrolled="true"] .brand {
    scale: var(--logo-scrolled-scale);
    translate: 0 var(--logo-scrolled-y);
  }
}
