/* Home: «Как это работает» (src/js/home/how-it-works.js) and «Лента покупок» (src/js/home/live-feed.js).
   Owner: how-live. Same light language as the rest of the page: white islands on the paper, Alumni Sans 900 upright
   (+ .oblique) for numerals, Golos Text for everything else, the brand blue for state. The blocks add no outer
   margins (the page grid in home.css spaces them). Motion: «Как это работает» lights its steps up once when it is
   first seen (plus one small move of a card's icon under the pointer); the live feed's own motion is described at
   its rules below. None of it under prefers-reduced-motion (base.css resets durations; the modules do not start
   theirs either). */

/* ==========================================================================
   Как это работает: the four steps in one row, as before — what changed is inside the card. Each island carries its
   mark in a filled disc on the left and, beside it, the numeral over the title over one sentence (owner 06.10.2026,
   from a reference she sent: «слева логотип Стима… 01, вход через Steam… чтобы оно не терялось на этом фоне»).

   What changed and why: the old cards carried a 28px line glyph in the top corner and a hairline border with no
   shadow, so on the paper background they read as four faint rectangles — the block had no anchor anywhere. The
   dark disc gives every step one, and the border + soft shadow lift the island off the paper. The thin arrow from
   card to card stays, now level with the discs it runs between.
   ========================================================================== */
.flow {
  --flow-gap: 16px;                  /* between the islands */
  --flow-link: #8DB5F8;              /* the connectors: the brand blue at about half strength */
  --flow-badge: 56px;                /* the disc: the island's anchor */
  --flow-unlit: #B9BDC6;             /* a numeral before the reveal lights it (motion, below) */
  container: flow / inline-size;
}

/* The switch: the site's segmented control at its own size. It used to be shrunk to 32px, and beside a 40px
   heading that read as a stray chip rather than a control (owner 06.10.2026: «как будто ни туда, ни сюда»). */
.flow__mode { flex: none; }

/* Both step lists share one cell, so the block keeps the height of the taller list whichever is shown. */
.flow__body { display: grid; grid-template-columns: minmax(0, 1fr); }
.flow__steps { grid-area: 1 / 1; display: grid; gap: var(--flow-gap); min-width: 0; margin: 0; }
.flow__steps[aria-hidden='true'] { visibility: hidden; }

/* The disc spans all three text rows and is centred against them, as in the reference. */
.flow-step {
  position: relative;                /* the connector to the next island hangs off it (the row layout) */
  display: grid;
  grid-template-columns: var(--flow-badge) minmax(0, 1fr);
  grid-template-areas: 'badge num' 'badge title' 'badge text';
  align-content: start;
  column-gap: 18px;
  min-width: 0;
  padding: 20px 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(25, 27, 32, .04), 0 14px 26px -18px rgba(25, 27, 32, .55);
}
/* The mark in the site's own blue, in a ring and not a filled disc (owner, 06.10.2026: «значки в цвет сайта и
   без заливки»). A solid dark disc was the heaviest thing on a light page and pulled the eye away from the words
   beside it; an outline carries the same anchor at a fraction of the weight. */
.flow-step__badge {
  grid-area: badge;
  align-self: center;
  display: grid;
  place-items: center;
  width: var(--flow-badge);
  height: var(--flow-badge);
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
}
.flow-step__badge svg { width: 28px; height: 28px; }
/* The Steam mark is a solid silhouette while the rest of the set is drawn in 1.75 lines, so at one size it reads
   heavier than its neighbours. A little smaller, and the four marks weigh the same. */
.flow-step__badge .steam-logo { width: 24px; height: 24px; }
/* ≥ 2rem: below that the slant is rasterised without hinting and the digits lose their shape (base.css) */
.flow-step__num {
  grid-area: num;
  font-family: var(--font-display);
  font-weight: 900;
  font-style: normal;
  font-synthesis: none;
  font-size: 2rem;
  line-height: .78;
  letter-spacing: .01em;
  color: var(--accent-strong);
  transform-origin: 0 100%;
  user-select: none;
}
.flow-step__title { grid-area: title; margin-top: 10px; font-size: var(--fs-md); font-weight: 600; line-height: 1.25; }
.flow-step__text { grid-area: text; margin-top: 4px; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink-2); }

/* The sizes below sit on .flow__steps, not on .flow: a container query cannot restyle the container it asks about.

   ---- wide blocks: all four islands in one row, as the block has always read (owner 06.10.2026: «всё должно было
   находиться в строчку… просто чуть-чуть должна поменяться структура внутри карточки»). A 300px card leaves about
   200px beside the disc, so the disc and the title step down a size and the sentence takes three lines. ---- */
@container flow (min-width: 1080px) {
  .flow__steps { grid-template-columns: repeat(4, minmax(0, 1fr)); --flow-badge: 48px; --flow-gap: 28px; }
  .flow-step { column-gap: 14px; padding: 18px 16px; }
  .flow-step__badge svg { width: 24px; height: 24px; }
  .flow-step__badge .steam-logo { width: 20px; height: 20px; }
  .flow-step__title { margin-top: 8px; font-size: var(--fs-base); }
  /* disc to disc: ::before is the line, ::after the head; 6px clear of either island */
  .flow-step:not(:last-child)::before {
    content: '';
    position: absolute;
    left: calc(100% + 7px);
    top: 50%;
    width: calc(var(--flow-gap) - 13px);
    height: 1.5px;
    margin-top: -.75px;
    border-radius: 1px;
    background: var(--flow-link);
    transform-origin: 0 50%;
  }
  .flow-step:not(:last-child)::after {
    content: '';
    position: absolute;
    left: calc(100% + var(--flow-gap) - 12.25px);
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-top: 1.5px solid var(--flow-link);
    border-right: 1.5px solid var(--flow-link);
    transform: rotate(45deg);
  }
}
/* ---- in between: two a row, the full-size disc ---- */
@container flow (min-width: 700px) and (max-width: 1079.98px) {
  .flow__steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* ---- narrow blocks: one island a row, a smaller disc so the sentence keeps its room ---- */
@container flow (max-width: 699.98px) {
  .flow__steps { --flow-badge: 48px; --flow-gap: 12px; }
  .flow-step { column-gap: 14px; padding: 16px 16px 17px; }
  .flow-step__badge svg { width: 24px; height: 24px; }
  .flow-step__title { margin-top: 8px; }
}

/* ---- motion: the one-time reveal and the icons' small moves (nothing loops) ---- */
@media (prefers-reduced-motion: no-preference) {
  /* how-it-works.js removes .is-waiting when the block is first seen: step after step, 0.4 s apart, the numeral
     takes the brand blue and the disc its ink. */
  .flow-step:nth-child(2) { --flow-i: 1; }
  .flow-step:nth-child(3) { --flow-i: 2; }
  .flow-step:nth-child(4) { --flow-i: 3; }
  .flow-step__num { transition: color 320ms var(--ease-out) calc(var(--flow-i, 0) * 400ms); }
  .flow-step__badge {
    transition:
      border-color 320ms var(--ease-out) calc(var(--flow-i, 0) * 400ms),
      color 320ms var(--ease-out) calc(var(--flow-i, 0) * 400ms);
  }
  .flow-step::before { transition: transform 260ms var(--ease-out) calc(var(--flow-i, 0) * 400ms + 160ms); }
  .flow-step::after { transition: opacity 120ms linear calc(var(--flow-i, 0) * 400ms + 340ms); }
  .flow.is-waiting .flow-step__num { color: var(--flow-unlit); transition: none; }
  .flow.is-waiting .flow-step__badge { border-color: var(--line-strong); color: var(--flow-unlit); transition: none; }
  .flow.is-waiting .flow-step::before { transform: scaleX(0); transition: none; }
  .flow.is-waiting .flow-step::after { opacity: 0; transition: none; }
}
/* Under the pointer a card's icon makes one small move: the Steam mark turns, the coin drops into the wallet, the
   bag lifts, the trade arrows swap, the check draws, the banknote slides out. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .flow-step--turn:hover .flow-step__badge svg { animation: flow-turn 560ms var(--ease-out); }
  .flow-step--lift:hover .flow-step__badge svg { animation: flow-lift 520ms var(--ease-out); }
  .flow-step--swap:hover .flow-step__badge svg { animation: flow-swap 560ms var(--ease-in-out); }
  .flow-step--out:hover .flow-step__badge svg { animation: flow-out 520ms var(--ease-out); }
  .flow-step--drop:hover .flow-ico__coin { animation: flow-drop 640ms var(--ease-in-out); }
  .flow-step--draw:hover .flow-ico__check { animation: flow-draw 420ms var(--ease-out); }
}
@keyframes flow-turn { 45% { transform: rotate(-30deg); } }
@keyframes flow-lift { 40% { transform: translateY(-3px) rotate(-7deg); } }
@keyframes flow-swap { to { transform: rotate(180deg); } }
@keyframes flow-out { 45% { transform: translate(3px, -3px); } }
@keyframes flow-drop {
  45% { transform: translateY(5px); opacity: 0; }
  46% { transform: translateY(-3px); opacity: 0; }
}
@keyframes flow-draw {
  from { stroke-dasharray: 1; stroke-dashoffset: 1; }
  to { stroke-dasharray: 1; stroke-dashoffset: 0; }
}

/* ==========================================================================
   Live-лента покупок: one row of same-size purchase cards, newest on the left, in a native horizontal scroller
   (snap per card, no scrollbar, a soft edge only where more cards are). Round arrows on the row's edges; new
   purchases enter at the left end (live-feed.js). With no purchases the section is [hidden] (base.css:
   display: none), so the page grid leaves no gap for it.
   ========================================================================== */
.live { container: live / inline-size; }

/* The title: a small red «on air» light, then «Live» drawn as a brand-blue outline (the hero's AURA idea) and the
   rest in ink. The light glows and breathes only while purchases are on screen (data-live-state, live-feed.js);
   loading or failed, it is a quiet grey dot. Reduced motion: it glows without breathing. */
.live__title { --live-red: #E5484D; }
.live__air {
  position: relative;
  display: inline-block;
  width: max(8px, .16em);
  height: max(8px, .16em);
  margin-right: .13em;
  border-radius: 50%;
  background: var(--live-red);
  box-shadow: 0 0 0 .045em rgba(229, 72, 77, .16);
  vertical-align: .24em;
  transition: background-color var(--dur-med) var(--ease-out), box-shadow var(--dur-med) var(--ease-out);
}
.live__air::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--live-red);
  opacity: 0;
  animation: live-air 2.4s cubic-bezier(.2, .7, .3, 1) infinite;
}
@keyframes live-air {
  0% { opacity: .5; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(2.8); }
}
.live:not([data-live-state='ready']) .live__air { background: var(--line-strong); box-shadow: none; }
.live:not([data-live-state='ready']) .live__air::after { animation: none; }
.live__on {
  color: transparent;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: max(1.5px, .028em) var(--accent);
  paint-order: stroke fill;
}

/* the sizes sit on the frame (row + arrows): a container query cannot restyle the container itself */
.live__frame {
  --live-card: 188px;          /* every card the same width … */
  --live-media: 125px;         /* … and the same 3:2 picture box, as the catalog cards */
  --live-gap: 12px;
  --live-fade: 56px;           /* the soft edges */
  --live-bleed-l: 0px;         /* phones: the row runs on to the screen edges (below) */
  --live-bleed-r: 0px;
  position: relative;
  min-width: 0;
}
.live__body { min-width: 0; }
.live__state { padding: 40px 24px; }

/* The window onto the row: a scroll container with its scrollbar hidden. The block padding, cancelled by the
   margin, keeps the hover lift and shadow inside its clip; the inline padding is the phone's screen gutter the
   row bleeds into. Scroll anchoring is off: live-feed.js keeps the view in place itself when cards come in. */
.live__viewport {
  --fade-l: var(--live-fade);
  --fade-r: var(--live-fade);
  position: relative;
  margin: -6px calc(-1 * var(--live-bleed-r)) -16px calc(-1 * var(--live-bleed-l));
  padding: 6px var(--live-bleed-r) 16px var(--live-bleed-l);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  overflow-anchor: none;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--live-fade);
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
}
.live__viewport::-webkit-scrollbar { display: none; }
/* only the side that has more to show fades */
.live__viewport.is-start { --fade-l: 0px; }
.live__viewport.is-end { --fade-r: 0px; }

/* (.live scope: beats base.css ul[role='list'] { padding: 0 }) */
.live .live__list {
  display: flex;
  gap: var(--live-gap);
  width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
}
.live__item { display: flex; flex: none; width: var(--live-card); scroll-snap-align: start; }

/* ---- the arrows: on the row's edges, centred on the pictures (the reviews' round arrows, lifted off the cards) */
.live__arrow {
  position: absolute;
  top: calc(var(--live-media) / 2);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(25, 27, 32, .06), 0 10px 24px -10px rgba(25, 27, 32, .38);
  cursor: pointer;
  transform: translateY(-50%);
  transition:
    opacity var(--dur-fast) var(--ease-out),
    visibility 0s linear 0s,
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.live__arrow[hidden] { display: none; }
.live__arrow svg { width: 20px; height: 20px; }
.live__arrow:hover { border-color: var(--accent); color: var(--accent-ink); }
.live__arrow:active { background: var(--accent-tint); }
.live__arrow:focus-visible { outline: none; box-shadow: var(--focus-ring), 0 10px 24px -10px rgba(25, 27, 32, .38); }
.live__arrow--prev { left: -12px; }
.live__arrow--next { right: -12px; }
/* nothing more on that side: the arrow fades out (and leaves the tab order and the accessibility tree) */
.live__arrow.is-off {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), visibility 0s linear var(--dur-fast);
}

/* ---- the card: buyer, picture, name (two lines of room), one meta line, price, time — one box for every item */
.live-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition:
    transform var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
a.live-card:hover {
  transform: translateY(-2px);
  border-color: rgba(55, 129, 252, .4);
  box-shadow: 0 2px 4px rgba(25, 27, 32, .04), 0 8px 16px -8px rgba(25, 27, 32, .16);
  color: var(--ink);
}
a.live-card:hover .live-card__name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
/* inside the clipped row the ring is drawn on the card's own edge */
a.live-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.live-card__media {
  position: relative;
  display: grid;
  /* one cell sized by the box, not by the picture (as .pcard__media-link): object-fit keeps the whole item inside */
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  flex: none;
  height: var(--live-media);
  overflow: hidden;
  color: var(--ink-3);
  /* a quiet neutral box, not the blue one the catalog cards use: this block sits under the page and should not
     out-shout it (owner 06.10.2026: «сделать эти карточки тоже чуть менее заметными») */
  background:
    radial-gradient(72% 80% at 50% 44%, rgba(232, 232, 228, .9) 0%, rgba(243, 243, 240, .5) 54%, rgba(255, 255, 255, 0) 84%),
    linear-gradient(180deg, #FAFAF8 0%, #FFFFFF 100%);
}
.live-card__media img {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 14px 14px 8px;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
/* Dota art: opaque 3:2 with a 1px frame → cover + slight scale hides the frame */
.live-card--art .live-card__media { background: #1E2129; }
.live-card--art .live-card__media img { padding: 0; object-fit: cover; transform: scale(1.06); }
.live-card__media .pcard__noimg svg { width: 28px; height: 28px; }
/* the item's rarity colour as a hairline under the picture, as on the games' own item tiles */
.live-card__media::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: var(--rarity, transparent);
}

.live-card__body { display: grid; gap: 4px; min-width: 0; padding: 10px 14px 13px; }
/* always two lines of room (a one-line name included): every card the same height */
.live-card__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  height: calc(2em * 1.3);
  overflow: hidden;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.live-card__meta {
  display: flex;
  gap: 6px;
  min-width: 0;
  height: 16px;
  overflow: hidden;
  font-size: var(--fs-xs);
  line-height: 16px;
  color: var(--ink-3);
  white-space: nowrap;
}
.live-card__game { flex: none; font-weight: 600; color: var(--ink-2); }
.live-dot { flex: none; color: var(--ink-3); }
/* a long last part («После полевых испытаний») ends in an ellipsis, not a cut-off letter */
.live-card__detail { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.live-card__price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  height: 22px;
  margin-top: 4px;
  line-height: 22px;
  color: var(--ink);
  white-space: nowrap;
}
.live-card__price .t-price { font-size: var(--fs-md); }
/* «куплено 58 сек назад», after a small green dot; even digits, so the ticking seconds do not shake the line */
.live-card__when {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 16px;
  overflow: hidden;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  line-height: 16px;
  color: var(--ink-3);
  white-space: nowrap;
}
.live-card__when::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-tint);
}
.live-card__when time { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* skeleton: the real card boxes with grey bars, so nothing moves when the row arrives */
.live__viewport--skeleton { overflow: hidden; }
.live__viewport--skeleton .skeleton { background: #E8E9E6; }
.live-card--skeleton .live-card__media { background: var(--surface-2); }
.live-card--skeleton .live-card__name { display: grid; align-content: center; gap: 7px; }
.live-card--skeleton .live-card__meta,
.live-card--skeleton .live-card__price { align-items: center; }
.live-card--skeleton .live-card__when::before { content: none; }
.live-sk__media { width: 58%; height: 58%; border-radius: 12px; }
.live-sk__line { display: block; height: 11px; border-radius: 6px; }
.live-sk__line--sm { height: 9px; }
.live-sk__price { display: block; width: 84px; height: 16px; border-radius: 6px; }

/* phone-width blocks: smaller cards (still all one size), smaller arrows, narrower edges */
@container live (max-width: 559.98px) {
  .live__frame { --live-card: 158px; --live-media: 105px; --live-gap: 10px; --live-fade: 16px; }
  .live-card { border-radius: 14px; }
  .live-card__media img { padding: 10px 10px 6px; }
  .live-card__body { gap: 3px; padding: 9px 10px 11px; }
  .live-card__name { font-size: var(--fs-sm); }
  .live-card__price .t-price { font-size: var(--fs-base); }
  /* «куплено 59 мин назад» whole on a 158px card */
  .live-card__when { gap: 5px; font-size: 11.5px; }
  .live-card__when::before { width: 5px; height: 5px; }
  .live__arrow { width: 40px; height: 40px; }
  .live__arrow svg { width: 18px; height: 18px; }
}
/* phones: the row runs on to the screen edges, the page gutter becomes its fade (as the reviews row); the arrows
   sit just inside the screen edges */
@media (max-width: 767.98px) {
  .live__frame { --live-bleed-l: var(--main-pad-left); --live-bleed-r: var(--main-pad-right); }
  .live__arrow--prev { left: calc(6px - var(--live-bleed-l)); }
  .live__arrow--next { right: calc(6px - var(--live-bleed-r)); }
}

@media (prefers-reduced-motion: reduce) {
  .live-card,
  .live__arrow { transition: none; }
  .live__air::after { animation: none; }
}
