/* Block «Популярное» on the main page, built from the "Ступени" prototype (steps.*).
   Self-contained: every class starts with pop-, tokens come from styles.css (--ivory, --basalt, --ochre,
   --charcoal, --ease, --font-*, --s-*, --gutter, --hit). To remove the block, delete this file,
   popular.js and the marked pieces in index.html.
   Changes against the prototype: dark ground (the page's language); flat ledges in the logo's
   colours with no shading gradients and no soft shadows; no parallax; names in the page's display
   face; the card is a dark panel. */

.pop {
  position: relative;
  /* top room for the fixed corner logo of the main page */
  padding: var(--s-8) 0 var(--s-5);
  overflow-x: hidden;
  overflow-x: clip;
  /* the ledges run out past both screen edges by design; clip them hard at the edges (also for their
     composited layers while they rise), so no sliver can show when iOS pulls the page sideways */
  clip-path: inset(-100vh 0 -100vh 0);
}
.pop__head { padding: 0 var(--gutter) var(--s-5); }
.pop__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  /* three words: a little smaller than the scene titles so «посетителей» keeps to the screen on phones */
  font-size: clamp(2.6rem, 12vw, 6.5rem);
  line-height: .86;
  letter-spacing: -.01em;
  text-transform: uppercase;
  text-wrap: balance;
  hyphens: none;
}
.pop__lead { margin: var(--s-4) 0 0; max-width: 32ch; opacity: .8; text-wrap: pretty; }

/* entrance: rise + fade once per step, transform/opacity only */
.js .pop-reveal { opacity: 0; transform: translate3d(0, 28px, 0); }
.js .pop-step.is-in .pop-reveal {
  opacity: 1;
  transform: none;
  transition: opacity 900ms var(--ease) var(--d, 0ms), transform 900ms var(--ease) var(--d, 0ms);
}
.pop-step.is-prep .pop-reveal { will-change: transform, opacity; }
.pop-step__ledge { --d: 0ms; }
.pop-step__plate { --d: 140ms; }

/* stairs: ledges grow out of the window edges and step down, left and right */
.pop-stairs { list-style: none; margin: 0; padding: 0; }
.pop-step { --sw: 92vw; position: relative; }
.pop-step + .pop-step { margin-top: calc(var(--sw) * -.055); }
.pop-step__stage {
  position: relative;
  display: block;
  width: var(--sw);
  padding-top: calc(var(--sw) * .17);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.pop-step--a .pop-step__stage { margin-left: calc(var(--sw) * -.045); }
.pop-step--b .pop-step__stage { margin-left: auto; margin-right: calc(var(--sw) * -.045); }
.pop-step__stage:focus-visible { outline-offset: -2px; }
.pop-step__float { position: relative; display: block; aspect-ratio: 600 / 270; }
.pop-step__ledge { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* ledge colours: the logo's bands, ochre and charcoal in turn; flat fills only.
   Name contrast: basalt on ochre 5.5:1, ivory on charcoal 12.9:1 */
.pop-step {
  --ledge-top: #CFB878;
  --ledge-riser: var(--ochre);
  --ledge-name: var(--basalt);
  --ledge-press: var(--charcoal);
  --ledge-name-pressed: var(--ivory);
}
.pop-step:nth-child(even) {
  --ledge-top: #847C6F;
  --ledge-riser: var(--charcoal);
  --ledge-name: var(--ivory);
  --ledge-press: var(--ochre);
  --ledge-name-pressed: var(--basalt);
}
.pop-ledge__top { fill: var(--ledge-top); }
.pop-ledge__riser { fill: var(--ledge-riser); }
.pop-ledge__lip { fill: none; stroke: rgba(255, 255, 255, .28); stroke-width: 1.2; vector-effect: non-scaling-stroke; }

.pop-step__name {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: .02em;
  text-transform: uppercase;
  fill: var(--ledge-name);
  transition: fill 320ms var(--ease);
}
.pop-step__press {
  fill: var(--ledge-press);
  opacity: 0;
  transform: scaleX(0);
  transform-box: fill-box;
  transform-origin: left center;
  transition: opacity 400ms var(--ease), transform 0s 400ms;
}
.pop-step--b .pop-step__press { transform-origin: right center; }
.pop-step__stage.is-pressed .pop-step__press { opacity: 1; transform: none; transition: transform 320ms var(--ease), opacity 0s; }
.pop-step__stage.is-pressed .pop-step__name { fill: var(--ledge-name-pressed); transition: fill 200ms var(--ease); }

.pop-step__plate { position: absolute; bottom: 22%; width: var(--pw, 60%); display: block; }
.pop-step--a .pop-step__plate { left: var(--px, 16%); }
.pop-step--b .pop-step__plate { right: var(--px, 16%); }
.pop-step__plate img { display: block; width: 100%; height: auto; transition: transform 620ms var(--ease); }
.pop-step__stage.is-pressed .pop-step__plate img { transform: translateY(3px) scale(.99); transition-duration: 200ms; }
.pop-step:nth-child(1) { --pw: 62%; --px: 15%; }
.pop-step:nth-child(2) { --pw: 54%; --px: 17%; }
.pop-step:nth-child(3) { --pw: 64%; --px: 14%; }
.pop-step:nth-child(4) { --pw: 54%; --px: 17%; }

/* text twin: beside the ledge on laptops, read into the card on phones */
.pop-step__copy { display: none; }
.pop-step__title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1.05; text-transform: uppercase; }
.pop-step__ingr, .pop-sheet__ingr { margin: var(--s-3) 0 0; font-size: 14px; line-height: 1.55; opacity: .72; text-wrap: balance; }
.pop-step__ingr::before, .pop-sheet__ingr::before {
  content: "";
  display: block;
  width: 40px;
  height: 1px;
  margin-bottom: var(--s-3);
  background: var(--ochre);
}
.pop-step__text, .pop-sheet__text { margin: var(--s-3) 0 0; max-width: 40ch; text-wrap: pretty; }

/* card: bottom sheet on phones, side card on laptops; dark panel, the page's buttons */
.pop-sheet { position: fixed; inset: 0; z-index: 50; visibility: hidden; pointer-events: none; }
.pop-sheet.is-shown { visibility: visible; }
.pop-sheet.is-open { pointer-events: auto; }
.pop-sheet__scrim {
  position: absolute;
  inset: 0;
  background: rgba(14, 14, 13, .6);
  opacity: 0;
  transition: opacity 420ms var(--ease);
  touch-action: none;
}
.pop-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92svh;
  padding: 0 var(--gutter) max(var(--s-5), calc(env(safe-area-inset-bottom) + var(--s-4)));
  background: var(--charcoal);
  color: var(--ivory);
  overscroll-behavior: contain;
  transform: translate3d(0, calc(100% + 40vw + 40px), 0);
  transition: transform 460ms var(--ease);
}
.pop-sheet.is-open .pop-sheet__scrim { opacity: 1; }
.pop-sheet.is-open .pop-sheet__panel { transform: translate3d(0, 0, 0); }
.pop-sheet.is-closing .pop-sheet__panel { transition: transform 580ms cubic-bezier(.45, 0, .2, 1); }
.pop-sheet.is-closing .pop-sheet__scrim { transition: opacity 660ms cubic-bezier(.45, 0, .2, 1); }
.pop-sheet.is-moving .pop-sheet__panel { will-change: transform; }
.pop-sheet.is-moving .pop-sheet__scrim { will-change: opacity; }
.pop-sheet__wave { position: absolute; bottom: calc(100% - 1px); left: 0; width: 100%; height: 26px; fill: var(--charcoal); }
.pop-sheet__plate { display: block; width: 62%; height: auto; margin: -24% auto var(--s-3); position: relative; }
.pop-sheet__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1;
  text-transform: uppercase;
  text-wrap: balance;
  hyphens: none;
}
.pop-sheet__text { opacity: .9; }
/* close cross, top right, 48px target */
.pop-sheet__x {
  position: absolute;
  z-index: 2;
  top: var(--s-2);
  right: var(--s-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--hit);
  height: var(--hit);
  border-radius: 50%;
  color: var(--ivory);
  -webkit-tap-highlight-color: transparent;
}
.pop-sheet__x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.pop-sheet__x:focus-visible { outline: 1px solid var(--ivory); outline-offset: -4px; }
/* grabber on phones: a short rounded bar centred on the top edge, the swipe handle */
.pop-sheet__grip {
  position: absolute;
  z-index: 2;
  top: -18px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 999px;
  background: rgba(241, 235, 225, .85);
  /* the plate overlaps the top of the card, so the bar keeps a dark edge to read over the food */
  box-shadow: 0 0 0 1px rgba(14, 14, 13, .45), 0 1px 6px rgba(14, 14, 13, .5);
  pointer-events: none;
}
/* swipe-down: the panel follows the finger (inline transform from popular.js), no transition while held */
.pop-sheet.is-dragging .pop-sheet__panel, .pop-sheet.is-dragging .pop-sheet__scrim { transition: none; }
.pop-sheet.is-closing.is-flung .pop-sheet__panel { transition: transform 460ms cubic-bezier(.32, .72, 0, 1); }
@media (max-width: 899px) { .pop-sheet__panel { touch-action: none; } }

@media (hover: hover) {
  .pop-step__stage:hover .pop-step__plate img { transform: translateY(-6px); }
}

@media (min-width: 900px) {
  .pop { padding-top: var(--s-8); }
  .pop__head { padding-bottom: var(--s-6); }
  .pop-step { --sw: min(60vw, 860px); }
  .pop-step + .pop-step { margin-top: calc(var(--sw) * -.08); }
  .pop-step__name { font-size: 28px; }
  .pop-step__copy {
    display: block;
    position: absolute;
    top: calc(var(--sw) * .2);
    width: min(34ch, calc(100vw - var(--sw) - 2 * var(--gutter)));
  }
  .pop-step--a .pop-step__copy { right: var(--gutter); }
  .pop-step--b .pop-step__copy { left: var(--gutter); }
  /* the riser carries the name: the heading stays for structure only */
  .pop-step__title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .pop-step__ingr { margin-top: 0; }

  .pop-sheet__panel {
    left: auto;
    top: 0;
    width: min(460px, 42vw);
    max-height: none;
    padding: var(--s-6);
    overflow-y: auto;
    transform: translate3d(calc(100% + 40px), 0, 0);
  }
  .pop-sheet__wave, .pop-sheet__grip { display: none; }
  .pop-sheet__plate { width: 86%; margin: var(--s-5) auto; }
}

@media (prefers-reduced-motion: reduce) {
  .js .pop-reveal { opacity: 1; transform: none; }
  .pop *, .pop-sheet, .pop-sheet * { transition-duration: 1ms !important; transition-delay: 0ms !important; }
}
