/* Depends on: base.css, viewport.css, section-1.css (the tab buttons
   reuse .s1-panel-link and its slide-swap hover wholesale). */

/* ============================================================
   SECTION 2 — Gościnnie
   ============================================================
   Two tabs on a plain paper ground, switched by a tab bar at the
   top: Gość specjalny (one portrait) and Panel dyskusyjny (four). The
   two decks overlap: the selected one stands in front with the other
   tucked behind it, only its right quarter showing. With the guest
   selected, their name in MonteCarlo sits to the left and the panel's
   four cards wait stacked behind; with the panel selected, the name
   column folds away and its four cards spread into a row. Nothing is
   revealed by scrolling — the section is all there the moment it
   arrives (data-max-step="0" in the markup).

   Hovering a front portrait turns it over to the frame on its back
   (and a click opens that back full size — see section-2.js); while
   the guest's card turns, the deck behind slides away to the right so
   it is not in the way, and comes back when the pointer leaves.
   ============================================================ */
#slide-s2 {
  background: var(--paper-2);
  color: var(--burgundy);

  /* The card is sized from its height; its width follows from
     frame_back.svg's 759.8:939.2. The vw term caps it by width, so the
     row (name column + the card pair, which is 1.25 cards wide) always
     fits across the screen. */
  --s2-card-h: min(66vh, 580px, 28vw * 939.2 / 759.8);
  --s2-card-w: calc(var(--s2-card-h) * 759.8 / 939.2);
  --s2-name-w: min(30vw, 560px);
  --s2-gap: clamp(16px, 3vw, 56px);
  /* Where the card behind goes while the front one is turning. */
  --s2-away: 108%;
}

/* ---- tab bar -------------------------------------------------- */
.s2-tabs {
  position: absolute;
  z-index: 2;
  top: calc(var(--header-h) + 2vh);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.2vw;
  padding: 0 4vw;
}
/* .s1-panel-link is paper-on-burgundy; this ground is paper, so the
   colours flip, and the label drops to Rubik's regular weight. */
.s2-tab {
  --s2-tab-fs: clamp(1rem, 1.9vw, 1.7rem);
  font-family: var(--display);
  font-weight: 400;
  /* Unselected tabs are 10% smaller. Done through font-size rather
     than a scale transform: .s1-panel-link's padding and border are in
     em, so the whole button shrinks with it, and transform stays free
     for the hover lift. */
  font-size: calc(var(--s2-tab-fs) * 0.9);
  color: var(--burgundy);
  border-color: var(--burgundy);
  cursor: pointer;
  transition:
    background 0.25s ease,
    color 0.25s ease,
    font-size 0.3s var(--ease),
    transform 0.2s var(--ease);
}
/* The selected tab: filled burgundy, paper text, full size. */
.s2-tab[aria-selected="true"] {
  font-size: var(--s2-tab-fs);
  background: var(--burgundy);
  color: var(--paper-2);
  cursor: default;
}
/* Hover on the unselected tab is only a light tint, so it never looks
   like the selected one. */
.s2-tab:not([aria-selected="true"]):hover {
  background: rgba(124, 17, 40, 0.12); /* var(--burgundy) at low opacity */
  color: var(--burgundy);
}
.s2-tab:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
/* The "*" marks the selected tab. Unselected tabs keep the mark's
   space but hide it, so the label does not jump sideways on switching. */
.s2-tab-mark {
  visibility: hidden;
}
.s2-tab[aria-selected="true"] .s2-tab-mark {
  visibility: visible;
}

/* ---- stage: name + card pair ---------------------------------- */
.s2-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: calc(var(--header-h) + 12vh) 4vw 4vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2-gap);
}

/* Both names occupy the same grid cell; the selected one fades in. */
.s2-names {
  flex: 0 0 auto;
  width: var(--s2-name-w);
  display: grid;
  align-items: center;
  text-align: center;
}
.s2-name {
  grid-area: 1 / 1;
  margin: 0;
  /* MonteCarlo is a script face and only ships a regular weight. */
  font-family: "MonteCarlo", cursive;
  font-weight: 400;
  font-size: clamp(3rem, 6.4vw, 7.4rem);
  line-height: 1.05;
  opacity: 0;
  transform: translateY(0.25em);
  transition:
    opacity 0.5s ease,
    transform 0.5s var(--ease);
}
.s2-name.is-active {
  opacity: 1;
  transform: none;
}

/* ---- the two decks -------------------------------------------- */
/* --s2-cw/--s2-ch are the size every card actually draws at. With the
   guest selected that is the full --s2-card-w; with the panel selected
   four cards (plus the guest's peeking quarter) have to share the row,
   so they all drop to --s2-pcard-w. The name column folds away at the
   same time to give them the room. */
.s2-stage {
  --s2-pgap: clamp(10px, 1.4vw, 24px);
  --s2-pcard-w: min(
    var(--s2-card-w),
    (92vw - 3 * var(--s2-pgap)) / 4.25
  );
  --s2-cw: var(--s2-card-w);
  --s2-ch: calc(var(--s2-cw) * 939.2 / 759.8);
  transition: gap 0.8s var(--ease);
}
.s2-stage[data-s2-active="panel"] {
  --s2-cw: var(--s2-pcard-w);
  gap: 0;
}
.s2-names {
  transition:
    width 0.8s var(--ease),
    opacity 0.4s ease;
}
.s2-stage[data-s2-active="panel"] .s2-names {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

/* Sized to the front deck plus the peeking quarter of the one behind;
   the decks themselves are stacked inside it. */
.s2-cards {
  flex: 0 0 auto;
  position: relative;
  width: calc(var(--s2-cw) * 1.25);
  height: var(--s2-ch);
  transition:
    width 0.8s var(--ease),
    height 0.8s var(--ease);
}
.s2-stage[data-s2-active="panel"] .s2-cards {
  width: calc(var(--s2-cw) * 4.25 + var(--s2-pgap) * 3);
}
.s2-deck {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--s2-cw);
  height: var(--s2-ch);
  /* Behind by default — .is-active brings one to the front. */
  z-index: 1;
  transform: translateX(var(--s2-back-x));
  /* Where this deck sits while it is the one behind: a quarter of a
     card to the right of the front one. */
  --s2-back-x: calc(var(--s2-cw) * 0.25);
  /* Greyed and softly blurred, so the one in front clearly reads as
     the selected tab. */
  filter: grayscale(1) blur(2px) brightness(0.95);
  cursor: pointer;
  /* z-index waits until the decks are halfway through their slide, so
     the stacking flips while they are moving past each other rather
     than as a pop at the start. Transitions (unlike the keyframes this
     used to have) never run on load, so nothing plays on arrival. */
  transition:
    transform 0.7s var(--ease),
    filter 0.4s ease,
    width 0.8s var(--ease),
    height 0.8s var(--ease),
    opacity 0.4s ease,
    visibility 0.4s,
    z-index 0s linear 0.3s;
}
/* The deck behind only peeks on first arrival, as a hint that there is
   a second tab. Once a tab has been switched (.s2-switched, added in
   section-2.js), the one not selected is hidden entirely, and the row
   drops the quarter-card it kept for the peek so the selected deck sits
   centred. */
.s2-stage.s2-switched .s2-deck:not(.is-active) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.s2-stage.s2-switched .s2-cards {
  width: var(--s2-cw);
}
.s2-stage.s2-switched[data-s2-active="panel"] .s2-cards {
  width: calc(var(--s2-cw) * 4 + var(--s2-pgap) * 3);
}
/* Behind the spread-out panel, the guest's card tucks in behind the
   fourth panel card instead, its right quarter showing past it. */
.s2-deck[data-s2-card="guest"] {
  --s2-back-x: calc(
    (var(--s2-cw) + var(--s2-pgap)) * 3 + var(--s2-cw) * 0.25
  );
}
.s2-deck.is-active {
  z-index: 2;
  transform: none;
  filter: none;
  cursor: auto;
}
/* While the guest's card is hovered (i.e. turning over), the panel
   deck behind it moves right out of its way, and slides back when the
   pointer leaves. */
.s2-stage[data-s2-active="guest"]
  .s2-cards:has(.s2-deck.is-active .s2-card:hover)
  .s2-deck:not(.is-active) {
  transform: translateX(var(--s2-away));
}

/* ---- cards within a deck -------------------------------------- */
/* Stacked on top of each other (first card on top) while the deck is
   behind; spread into a row, one card + gap apart, once it is the
   selected one. --i is each card's place in its deck. */
.s2-card {
  --i: 0;
  position: absolute;
  inset: 0;
  perspective: 1400px;
  z-index: 4;
  transition: transform 0.8s var(--ease);
}
.s2-card:nth-child(2) { --i: 1; z-index: 3; }
.s2-card:nth-child(3) { --i: 2; z-index: 2; }
.s2-card:nth-child(4) { --i: 3; z-index: 1; }
.s2-deck.is-active .s2-card {
  transform: translateX(calc(var(--i) * (100% + var(--s2-pgap))));
  cursor: pointer;
}
/* Panellists not announced yet: the photo is covered by a plain
   burgundy panel reading "Wkrótce". No flip, no popup. */
.s2-card--locked .s2-face-front::after {
  content: "Wkrótce";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--burgundy);
  color: var(--paper-2);
  font-family: "MonteCarlo", cursive;
  font-weight: 400;
  font-size: calc(var(--s2-ch) * 0.13);
}
.s2-deck.is-active .s2-card--locked {
  cursor: default;
}

.s2-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.9s var(--ease);
}
/* The front cards idle with a slow wobble, hinting they can be turned —
   staggered so a row of them does not rock in lockstep. */
.s2-deck.is-active .s2-card:not(.s2-card--locked) .s2-card-inner {
  animation: s2Tease 4.5s ease-in-out infinite;
  animation-delay: calc(1.1s + var(--i) * 0.7s);
}
@keyframes s2Tease {
  0%,
  100% {
    transform: rotateY(-13deg);
  }
  50% {
    transform: rotateY(13deg);
  }
}
/* Hover turns a front card over to its back. `animation: none` is
   what lets the transition take charge — the wobble would otherwise
   keep winning over any transform set here. */
.s2-deck.is-active .s2-card:not(.s2-card--locked):hover .s2-card-inner,
.s2-deck.is-active .s2-card:not(.s2-card--locked):focus-within .s2-card-inner {
  animation: none;
  transform: rotateY(180deg);
}
.s2-face {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.s2-face-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.s2-face-back {
  transform: rotateY(180deg);
  background: url("../assets/images/s2/frame_back.svg") center / 100% 100%
    no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  /* The frame art draws its own border, so the copy is inset well
     inside it rather than filling the face. */
  padding: 12% 11%;
}
.s2-back-copy {
  font-family: var(--body);
  color: var(--paper-2);
  /* Sized off the CARD, not the viewport. The card stops growing at
     its size ceiling, so a vh-based size kept growing past
     it on tall screens and pushed the copy into a scrollbar. As a
     fraction of the card, the whole back face scales as one piece and
     the copy fits at every card size. 0.026 is the largest ratio that
     still clears the frame with the logo above it. */
  font-size: calc(var(--s2-ch) * 0.026);
  line-height: 1.45;
  text-align: center;
  /* Long copy in a fixed frame: let it scroll rather than spill out of
     the art if a short viewport squeezes it. */
  max-height: 100%;
  overflow-y: auto;
}
/* The panel's cards are smaller (four share the row) and carry much
   less copy, so their type is a larger share of the card to stay
   readable. */
.s2-deck[data-s2-card="panel"] .s2-back-copy {
  font-size: calc(var(--s2-ch) * 0.034);
}
/* A panellist's name, between the logo and the copy — in the same
   MonteCarlo script the guest's name uses beside the cards. */
.s2-back-copy .s2-back-name {
  margin: 0 0 0.3em;
  font-family: "MonteCarlo", cursive;
  font-weight: 400;
  font-size: 2.8em;
  line-height: 1.05;
}
/* The brand lockup heading the back of the card. Flat #0bbbef art, so
   it is stencilled over a paper-2 fill — the same approach as the
   header logo and the wallpaper motifs. */
.s2-back-logo {
  display: block;
  width: 64%;
  margin: 0 auto 0.9em;
  aspect-ratio: 775.2 / 238.42;
  background-color: var(--paper-2);
  -webkit-mask-image: url("../assets/images/logo/brand_logo-logotype.svg");
  mask-image: url("../assets/images/logo/brand_logo-logotype.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.s2-facts {
  list-style: none;
  margin: 0 0 1.1em;
  padding: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15em;
  line-height: 1.25;
}
.s2-facts li + li {
  margin-top: 0.45em;
}
.s2-back-copy p {
  margin: 0 0 0.8em;
}
.s2-back-copy p:last-child {
  margin-bottom: 0;
}

/* ============================================================
   Narrow screens: stacked
   ============================================================ */
@media (max-width: 860px) {
  #slide-s2 {
    /* The vh term keeps a short phone from pushing the card (and the
       name stacked above it) off the bottom of the screen. */
    --s2-card-w: min(81vw, 390px, 52vh * 759.8 / 939.2);
    --s2-card-h: calc(var(--s2-card-w) * 939.2 / 759.8);
  }
  .s2-tabs {
    gap: 2vw;
  }
  .s2-tab {
    --s2-tab-fs: clamp(0.85rem, 3.6vw, 1.2rem);
  }
  .s2-stage {
    flex-direction: column;
    padding: calc(var(--header-h) + 10vh) 6vw 3vh;
    gap: 2.4vh;
    /* The panel does not spread into a row here (see below), so its
       cards keep the full card size. */
    --s2-pcard-w: var(--s2-card-w);
  }
  .s2-names {
    width: 100%;
    max-height: 40vh;
    transition:
      max-height 0.8s var(--ease),
      opacity 0.4s ease;
  }
  /* Stacked, the name sits above the cards rather than beside them, so
     it is its height that has to fold away for the panel, not its width. */
  .s2-stage[data-s2-active="panel"] .s2-names {
    width: 100%;
    max-height: 0;
  }
  .s2-name {
    font-size: clamp(2.6rem, 11vw, 4.2rem);
  }
  /* ---- the portrait taps open instead of flipping ----
     On a touch screen a tap leaves :hover stuck on, so the card would
     sit there reversed, showing copy far too small to read at this
     width, and the deck behind would stay pushed away. Re-stating the
     idle wobble beats the flip, the deck behind keeps its place, and a
     tap opens the popup instead (js/section-2.js). */
  .s2-deck.is-active .s2-card:not(.s2-card--locked):hover .s2-card-inner,
  .s2-deck.is-active .s2-card:not(.s2-card--locked):focus-within .s2-card-inner {
    animation: s2Tease 4.5s ease-in-out infinite;
    animation-delay: calc(1.1s + var(--i) * 0.7s);
  }
  .s2-stage[data-s2-active="guest"]
    .s2-cards:has(.s2-deck.is-active .s2-card:hover)
    .s2-deck:not(.is-active) {
    transform: translateX(var(--s2-back-x));
  }

  /* ---- the panel as a swipeable stack ----
     Four cards in a row would be thumbnail-sized at this width, so the
     panel stays one stack: the current card on top, the rest shrinking
     away behind it and peeking over its top edge. A sideways swipe
     flings the top card off and brings the next one up; a tap opens the
     top card's back in the popup (all in js/section-2.js, which sets
     each card's --pos: 0 on top, then 1, 2, 3 going back). */
  /* Only the selected deck shows here — no peeking deck behind it (the
     tabs switch between them). The row is one card wide to match, so the
     deck that is showing sits centred. */
  .s2-cards,
  .s2-stage[data-s2-active="panel"] .s2-cards,
  .s2-stage.s2-switched[data-s2-active="panel"] .s2-cards {
    width: var(--s2-cw);
  }
  .s2-deck:not(.is-active) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .s2-deck {
    transition:
      transform 0.7s var(--ease),
      filter 0.4s ease,
      opacity 0.4s ease,
      visibility 0.4s,
      z-index 0s linear 0.3s;
  }
  .s2-deck[data-s2-card="guest"] {
    --s2-back-x: calc(var(--s2-cw) * 0.25);
  }
  .s2-deck.is-active .s2-card {
    z-index: calc(10 - var(--pos, 0));
    transform: translateY(calc(var(--pos, 0) * -6%))
      scale(calc(1 - var(--pos, 0) * 0.07));
    transition: transform 0.35s var(--ease);
  }
  /* The top card on its way off (or, swiping back, on its way in). */
  .s2-deck.is-active .s2-card.s2-card--fling {
    z-index: 20;
    transform: translateX(calc(var(--fling, -1) * 120%))
      rotate(calc(var(--fling, -1) * 12deg));
  }
  .s2-deck.is-active .s2-card.s2-card--instant {
    transition: none;
  }
  /* Which card of the four is on top. */
  .s2-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
  }
  .s2-stage[data-s2-active="panel"] .s2-dots {
    opacity: 1;
  }
  .s2-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--burgundy);
    opacity: 0.25;
    transition: opacity 0.3s ease;
  }
  .s2-dots span.is-active {
    opacity: 1;
  }
}
/* The stack's dots are a phone-only thing. */
@media (min-width: 861px) {
  .s2-dots {
    display: none;
  }
}

/* ============================================================
   The card's back, as a popup (every width — see section-2.js)
   ============================================================ */
.modal.s2-back-modal {
  background: var(--paper-2);
}
/* The same frame art the card's back face uses, at the same aspect
   ratio, so the popup reads as that card enlarged rather than as a
   different thing. --s2-card-h is redefined here as this frame's own
   height: the cloned .s2-back-copy sizes its type off that property
   (see the note on it above), and outside #slide-s2 it would otherwise
   be undefined and the copy would fall back to an inherited size. */
.s2-back-modal-frame {
  /* Capped against the viewport HEIGHT as well as its width: the frame
     keeps the card's 759.8:939.2 proportions, so a width-only cap made
     it ~1.24x as tall as it is wide and a short desktop window ran the
     bottom of the frame off screen. */
  --s2-frame-w: min(92vw, 460px, 86vh * 759.8 / 939.2);
  width: var(--s2-frame-w);
  aspect-ratio: 759.8 / 939.2;
  background: url("../assets/images/s2/frame_back.svg") center / 100% 100%
    no-repeat;
  display: flex;
  /* stretch, not centre: the copy is meant to fill the frame's inside
     and scroll there — see the rule below. */
  align-items: stretch;
  justify-content: center;
  /* Tighter than the card's own 12%/11%: the frame is only as wide as a
     phone here, and every percent of inset is a line of copy that has
     to be scrolled for instead of read. Still well clear of the drawn
     border.

     Written as a calc against --s2-frame-w rather than as a plain
     percentage, which is the one thing that does NOT work here: a
     percentage padding resolves against the CONTAINING BLOCK's width,
     and this frame's containing block is the full-screen modal. A
     literal `9%` was therefore 9% of the whole viewport — around 138px
     of inset on a 460px-wide frame, which squeezed the copy into a
     narrow strip down the middle and left it scrolling with the frame
     empty around it. On the card itself the same percentages are fine,
     because there the containing block IS the card. */
  padding: calc(var(--s2-frame-w) * 0.09) calc(var(--s2-frame-w) * 0.08);
}
/* The copy is sized against the CARD on the card (a fraction of
   --s2-card-h — see the note where that is set), which is right there
   and wrong here: this frame is as large as the screen allows, and
   tying the type to it would just shrink the text on the smallest
   phones, which are exactly the ones that need it biggest. A readable
   floor with room to grow is what this wants instead.

   The frame keeps the card's proportions rather than stretching to fit
   the text — the art has drawn corners and ornament that distort badly
   when pulled out of shape. The consequence is that this much copy
   cannot all be on screen at once on a small phone, so it scrolls
   inside the frame, exactly as it already does on the card itself. */
.s2-back-modal-frame .s2-back-copy {
  font-size: clamp(0.82rem, 3.4vw, 1.05rem);
  /* Fill the frame and scroll inside it, rather than being sized to the
     copy and capped with a percentage max-height — as a centred flex
     item that percentage resolved against the wrong box and left the
     text scrolling in a short strip with the rest of the frame empty
     around it. flex + min-height:0 is the same shape of fix the tagline
     modal's own scrolling body uses (see section-1.css). */
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  /* Short copy (Darek's back) sat at the top of the frame with the
     rest of it empty. Auto margins on the first and last child centre
     it vertically; unlike justify-content:center they collapse to zero
     once the copy is taller than the frame, so long copy (Bobo's) still
     starts at the top and scrolls instead of being cut off above. */
  display: flex;
  flex-direction: column;
}
.s2-back-modal-frame .s2-back-copy > :first-child {
  margin-top: auto;
}
.s2-back-modal-frame .s2-back-copy > :last-child {
  margin-bottom: auto;
}
