/* Depends on: base.css, viewport.css. */

/* ============================================================
   SECTION 6 — two text/photo pairs, then a photo grid finale.
   ============================================================
   Step 0: intro text on the LEFT, first (landscape) photo on the
   RIGHT, sized to the same height as the text block.
   Step 1: second line of text on the RIGHT, second (portrait)
   photo on the LEFT, sized so its WIDTH matches the text block's
   height instead (a tall photo standing next to short text reads
   oddly if you match heights, so the matched dimension flips).
   Both pairs are vertically centered — section-6.js measures each
   pair's text box and sets the sibling photo's height/width inline
   to match (see s6SizePhoto()); this file only supplies the layout
   and a sensible fallback size for before that JS runs.
   Complete (one more scroll past step 1): the pairs fade out and a
   photo collage fades in — all 8 photos flowing down 4 masonry
   columns, each kept at its own source aspect ratio (no cropping),
   with "NASZE WSPOMNIENIA 2025" floating centred on top of it in its
   own label chip rather than occupying a cell of the collage itself.
   ============================================================ */
#slide-s6 {
  background: var(--ink);
  color: var(--paper);
}
.s6-stage {
  position: absolute;
  inset: 0;
  padding-top: var(--header-h);
}

/* ----------------------------------------------------------------
   The two text/photo pairs
   ---------------------------------------------------------------- */
.s6-pairs {
  position: absolute;
  inset: 0;
  padding-top: var(--header-h);
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease;
}
.s6-stage.s6-complete .s6-pairs {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.s6-pair {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4vw;
  padding: 0 7vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.s6-pair.active {
  opacity: 1;
  pointer-events: auto;
}

.s6-pair-text {
  flex: 0 1 42%;
  min-width: 0;
}
.s6-pair-text p {
  font-family: var(--display);
  font-weight: 800;
  color: var(--orange);
  line-height: 1.44;
  letter-spacing: 0.01em;
  font-size: clamp(1.2rem, 2.6vw, 2rem);
}
.s6-pair-a .s6-pair-text p {
  text-align: left;
}
.s6-pair-b .s6-pair-text p {
  text-align: right;
}

.s6-pair-photo {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
/* Fallback sizing (before section-6.js's ResizeObserver measures the
   text and sets an inline height/width to match it exactly) — keeps
   both photos sane-looking on first paint and if JS is disabled. */
.s6-pair-photo img {
  display: block;
  max-width: 44vw;
  max-height: 60vh;
  width: auto;
  height: auto;
}

@media (max-width: 760px) {
  .s6-pair {
    flex-direction: column;
    justify-content: center;
    gap: 3vh;
    padding: 0 6vw;
  }
  .s6-pair-b {
    flex-direction: column-reverse;
  }
  .s6-pair-text {
    flex: none;
  }
  .s6-pair-a .s6-pair-text p,
  .s6-pair-b .s6-pair-text p {
    text-align: center;
  }
  .s6-pair-photo img {
    max-width: 74vw;
    max-height: 38vh;
    /* On narrow screens the pairs stack instead of sitting side by
       side, so section-6.js skips its height/width-matching maths
       here and leaves sizing to these rules. */
    height: auto !important;
    width: auto !important;
  }
}

/* ----------------------------------------------------------------
   The finale — the label, then the photos, then the arrows
   ----------------------------------------------------------------
   One set of 8 photo cards, two layouts:
     wide   — two rows of four, all 8 on screen at once.
     narrow — the same cards collapse into a single stack, sitting
              exactly on top of each other with no offset, only the
              active one visible; the arrows page through them, and
              each end's arrow hides once you reach it (see
              s6UpdateArrows() in section-6.js).
   The arrows are the same bare hand-drawn stroke as Section 5's
   (.s5-arrow), so the two sections' controls read as one family.
   ---------------------------------------------------------------- */
.s6-grid-stage {
  position: absolute;
  inset: 0;
  padding: var(--header-h) 4vw 4vh;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}
.s6-stage.s6-complete .s6-grid-stage {
  opacity: 1;
  visibility: visible;
}

.s6-finale {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.4vh;
  width: 100%;
  max-width: 1500px;
}

.s6-finale-label {
  text-align: center;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: clamp(1.1rem, 2.2vw, 1.9rem);
  color: var(--orange);
}

/* Wide: two rows of four. */
.s6-photos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: min(1.6vw, 20px);
  width: 100%;
}
.s6-photo-card {
  margin: 0;
  overflow: hidden;
  background: rgba(242, 235, 220, 0.06);
}
.s6-photo-card img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: transform 0.4s var(--ease);
}
.s6-photo-card img:hover {
  transform: scale(1.04);
}

/* The arrows only have a job once the photos are stacked — with all
   eight on screen there is nothing to page through. */
/* Three fixed slots rather than a centred flex row: an arrow hiding
   itself at either end then leaves its slot behind, so the counter
   between them stays put instead of sliding sideways. */
.s6-photo-nav {
  display: none;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.4em;
}
.s6-photo-nav .s6-arrow.left {
  justify-self: end;
}
.s6-photo-nav .s6-arrow.right {
  grid-column: 3;
  justify-self: start;
}
.s6-arrow {
  flex: none;
  border: none;
  background: none;
  padding: 0;
  color: var(--orange);
  display: flex;
  align-items: center;
  cursor: pointer;
  transition:
    color 0.2s ease,
    transform 0.2s var(--ease);
}
.s6-arrow:hover {
  transform: scale(1.1);
}
.s6-arrow-icon {
  width: 56px;
  height: 28px;
  stroke: currentColor;
}
.s6-arrow.left .s6-arrow-icon {
  transform: scaleX(-1);
}
/* At either end of the stack the arrow that would go further that way
   is removed outright rather than greyed out — section-6.js sets the
   native `disabled` attribute on it, same as Sections 4 and 5. */
.s6-arrow:disabled {
  display: none;
}
.s6-photo-counter {
  /* Pinned rather than auto-placed: with an end's arrow hidden, grid
     auto-placement would otherwise slide the counter into the empty
     first column. */
  grid-column: 2;
  min-width: 4em;
  text-align: center;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--paper-2);
  opacity: 0.7;
}

/* Narrow: the same eight cards, stacked with no offset. This is the
   one-at-a-time "featured" view, so the photos are contained rather
   than cropped to a common tile shape the way the two-row grid above
   crops them — a landscape shot squeezed into a portrait frame loses
   more than half its width. */
@media (max-width: 900px) {
  /* Shared by the stack and the arrow row below it, so the arrows line
     up with the photo's own edges and — since that gives the row a
     definite width — the counter stays dead centre even when an end's
     arrow hides itself. */
  .s6-finale {
    --s6-stack-w: min(84vw, 460px);
  }
  .s6-photos {
    display: block;
    position: relative;
    width: var(--s6-stack-w);
    height: min(52vh, 560px);
  }
  .s6-photo-card {
    position: absolute;
    inset: 0;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
  }
  .s6-photo-card.active {
    opacity: 1;
    pointer-events: auto;
  }
  .s6-photo-card img {
    height: 100%;
    aspect-ratio: auto;
    object-fit: contain;
  }
  .s6-photo-card img:hover {
    transform: none;
  }
  .s6-photo-nav {
    display: grid;
    width: var(--s6-stack-w);
  }
  .s6-arrow-icon {
    width: 44px;
    height: 22px;
  }
}
