/* X30 wheel of prizes — the open state.
 *
 * It is packaged with the widget instead of the brand pack for the same reason
 * the structural rules are inlined: a project stylesheet that forgets a rule
 * must not be able to publish a broken wheel. The page loads it without
 * blocking the first paint, because nothing it styles is visible until the
 * visitor opens the dialog.
 *
 * The disc itself is drawn into the page by the build; everything here is the
 * paper card it sits on, the pointer, the hub and the result panel. Tokens are
 * read from the brand pack when it defines them and fall back to the club's own
 * values when it does not, so the wheel is never unstyled.
 */

.wheel-launcher {
  position: fixed;
  right: clamp(14px, 2.2vw, 28px);
  /* Above the telephone conversion bar, never on top of it. */
  bottom: calc(clamp(14px, 2.2vw, 28px) + var(--sticky-h, 0px));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.6em 1.15em 0.6em 0.7em;
  background: var(--paper-3, #fffdfa);
  color: var(--ink, #141e4a);
  border: 1px solid var(--line, rgba(20, 30, 74, 0.13));
  border-radius: 999px;
  box-shadow: 0 20px 44px -22px rgba(20, 30, 74, 0.6);
  cursor: pointer;
  /* Inherit, do not demand. Naming a face here asked every page for Comfortaa,
   * including the pages that deliberately dropped it — this one removed it in
   * July because it fought the numerals — and the launcher then rendered in a
   * face that appears nowhere else, which is a large part of why it read as
   * something that had wandered in from another document. */
  font-family: var(--display-font, inherit);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.1;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.25s ease,
    visibility 0s linear 0s;
}

/* Hidden rather than merely transparent: a launcher a mouse cannot reach must
 * not be the next stop of the Tab key either. */
.wheel-launcher[data-x30-away] {
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.25s ease, visibility 0s linear 0.25s;
}

.wheel-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 26px 52px -22px rgba(20, 30, 74, 0.65);
}

.wheel-launcher .gift {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  background: var(--paper-2, #f3ece1);
}

/* The pill and the dialog are the same offer: only one of them is ever on
 * screen. It used to float on top of its own backdrop. */
body:has(dialog.wheel-dialog[open]) .wheel-launcher {
  display: none;
}

/* On a telephone the words are the mark. A 217px pill parked over the body
 * copy for the whole scroll is an obstruction, not an offer. */
@media (max-width: 720px) {
  .wheel-launcher {
    padding: 5px;
    gap: 0;
  }
  .wheel-launcher-copy {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

dialog.wheel-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(560px, calc(100vw - 24px));
  width: 100%;
  color: var(--ink, #141e4a);
  /* The card is taller than a wheel: the three prizes stand over the disc, the
   * telephone and two consents stand under it, and a refusal adds a line on top
   * of that. The dialog is therefore height-capped — but it is NOT the
   * scroller. Scrolling the whole card is what pushed «Крутить!» off the bottom
   * of every telephone: at 375×812 its foot measured 849px. The card is a
   * column instead, with the scroll inside it and the button below the scroll.
   */
  max-height: calc(100vh - 20px);
  max-height: calc(100dvh - 20px);
  overflow: visible;
}

/* Not on the bare `dialog.wheel-dialog`: a closed native dialog is display:none
 * by the user agent, and a display of our own would publish the card to a page
 * whose script never ran. `[open]` is the state this layout describes. */
dialog.wheel-dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog.wheel-dialog::backdrop {
  background: rgba(16, 23, 56, 0.62);
}

/* The card fills the height it is allowed and no more. The club's brand pack
 * gives it `max-height: 92vh; overflow: auto` of its own, which used to make it
 * a second scroller nested inside the dialog; here it must be neither — the
 * scrollport is `.wheel-scroll` and nothing else. Two classes so this wins over
 * the brand pack whatever the load order. */
.wheel-dialog .wheel-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: visible;
}

.wheel-card {
  background: var(--paper, #faf6f0);
  border-radius: 26px;
  padding: clamp(20px, 3vw, 32px);
  box-shadow: 0 50px 90px -40px rgba(8, 14, 40, 0.8);
  position: relative;
  text-align: center;
  animation: x30-wheel-pop 0.32s cubic-bezier(0.2, 0.75, 0.3, 1) both;
}

/* EVERYTHING THE VISITOR READS. It gives up room before the button does.
 *
 * `flex: 0 1 auto` and not `1 1 auto`: on a tall screen nothing scrolls and the
 * button must sit directly under the last consent, not be pushed to the foot of
 * an empty card. */
.wheel-dialog .wheel-scroll {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* A focus ring is drawn outside the box it belongs to; without this the
   * scrollport clips the ring off the telephone field's left edge. */
  padding: 0 3px;
  margin: 0 -3px;
}

/* THE PORT SCROLLS DOWN, NEVER SIDEWAYS.
 *
 * The telephone row is a flex item whose automatic minimum size is the width
 * of the input's own idea of twenty characters — 288px. That never showed
 * while the card merely overflowed; inside a scrollport it became a sideways
 * scroll, and on a 320px telephone (SE, Fold cover) the browser, going to the
 * focused field, opened the window scrolled 24px right: the prize names ran
 * under the close button and «Телефон родителя» lost its first letters.
 *
 * `min-width: 0` lets the form be as narrow as the card. The field is still
 * 210px wide at 320 — a mask of eleven digits with room to spare.
 */
.wheel-dialog .wheel-ask {
  min-width: 0;
}

/* THE ONE CONTROL THE DIALOG EXISTS FOR. It is outside the scrollport, so it is
 * on screen at 667, 740, 812, 844 and 932 alike — a visitor who opens a wheel
 * has to be able to see what turns it without dragging anything. */
.wheel-dialog .wheel-foot {
  flex: none;
  padding-top: clamp(12px, 1.6vw, 16px);
  /* A breath of shade under the last line the port can show, so that a card
   * which continues under the button says so. Deliberately faint: on a screen
   * where nothing scrolls there is nothing to signal, and a hard rule over the
   * button would then read as a second divider under the consents. */
  box-shadow: 0 -16px 16px -18px rgba(20, 30, 74, 0.32);
}

@keyframes x30-wheel-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.wheel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line, rgba(20, 30, 74, 0.13));
  background: var(--paper-3, #fffdfa);
  color: var(--ink-soft, #4a5478);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.wheel-close:hover {
  color: var(--ink, #141e4a);
  background: var(--paper-2, #f3ece1);
}

.wheel-card .k {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue, #314cb6);
  font-weight: 600;
  margin: 0;
}

.wheel-card h2 {
  font-size: clamp(1.24rem, 1rem + 0.9vw, 1.6rem);
  margin: 0.5em auto;
  max-width: 22em;
}

/* THE NARROWEST TELEPHONE STILL IN USE. On a 320px screen the card is 296px
 * wide, the centred title measures 246 and the close button occupies the last
 * 50 of them: «Колесо подарков клуба» ended with its last letter under the ×.
 * Held to widths this title cannot clear on its own, so that at 375 and up it
 * keeps the single line the height budget was measured against. */
@media (max-width: 359px) {
  .wheel-card h2 {
    padding: 0 30px;
  }
}

.wheel-card .sub {
  color: var(--ink-soft, #4a5478);
  font-size: 0.94rem;
  max-width: 30em;
  margin: 0 auto;
  line-height: 1.55;
}

/* Once a prize has been announced, «что можно выиграть» is behind the visitor.
 * Three offers standing over one result is an invitation to misread which of
 * them she actually got. */
.wheel-card[data-x30-wheel-state="result"] .sub,
.wheel-card[data-x30-wheel-state="result"] .wheel-prizes,
.wheel-card[data-x30-wheel-state="known"] .sub,
.wheel-card[data-x30-wheel-state="known"] .wheel-prizes {
  display: none;
}

/* WHAT SHE CAME FOR.
 *
 * Three rewards, once each, between the headline and the disc — the first
 * thing read after the title and the last thing that may be quiet. The wedges
 * carry the same words because the pointer has to stop on one of them, but the
 * wedges are a diagram; this is the sentence. Set at the size of body copy and
 * bold, in the deep brand blue, so it outweighs every line of supporting text
 * left in the dialog. */
.wheel-prizes {
  list-style: none;
  margin: clamp(12px, 1.6vw, 18px) auto 0;
  padding: 0;
  max-width: 24em;
  text-align: left;
  display: grid;
  gap: 0.42em;
}

.wheel-prizes li {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  font-family: var(--display-font, inherit);
  font-weight: 700;
  font-size: clamp(1.02rem, 0.94rem + 0.4vw, 1.18rem);
  line-height: 1.28;
  color: var(--blue-deep, #2d4192);
}

.wheel-prizes .swatch {
  flex: none;
  width: 0.72em;
  height: 0.72em;
  border-radius: 50%;
  /* The sector this line names. A ring, so a sand swatch is still a disc on
   * paper of almost the same value. */
  box-shadow: 0 0 0 1px rgba(20, 30, 74, 0.22);
  transform: translateY(0.02em);
}

.wheel-stage {
  position: relative;
  width: min(320px, 74vw);
  margin: clamp(16px, 2.4vw, 24px) auto 0;
}

.wheel-svg {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 22px 34px rgba(20, 30, 74, 0.28));
}

[data-x30-wheel-rotor] {
  transform-origin: 50% 50%;
}

/* The label carries its own counter-rotation in the user space of the
 * viewBox, so `translate(160px,160px)` means the centre of the disc and
 * nothing else. Without this the script's transform would be measured from
 * the label's own bounding box and the words would fly off the wheel. */
.wheel-label {
  transform-box: view-box;
  transform-origin: 0 0;
}

.wheel-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 27%;
  height: 27%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--paper-3, #fffdfa);
  color: var(--blue, #314cb6);
  box-shadow: 0 6px 18px rgba(20, 30, 74, 0.28), 0 0 0 5px rgba(250, 246, 240, 0.9);
  display: grid;
  place-items: center;
  padding: 6.5%;
}

.wheel-hub svg {
  width: 100%;
  height: auto;
}

.wheel-pointer {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
  filter: drop-shadow(0 3px 5px rgba(20, 30, 74, 0.35));
}

.wheel-actions {
  margin-top: clamp(18px, 2.4vw, 26px);
}

.wheel-actions .btn,
.wheel-result .btn {
  min-width: 200px;
}

/* WHAT THE SPIN COSTS.
 *
 * The telephone stands over the button, not after it. The card is centred
 * because a wheel is; a form is not, so the ask turns the alignment back and
 * takes the page's own field component with it — `.field`, `.phone-row`,
 * `.consent`, `.hint` and `.error` are the brand pack's, and are deliberately
 * not restyled here. What is left is the box they stand in. */
.wheel-ask {
  text-align: left;
  max-width: 25.5em;
  margin: 0 auto;
  padding-top: clamp(14px, 2vw, 20px);
  border-top: 1px solid var(--line, rgba(20, 30, 74, 0.13));
}

.wheel-foot .wheel-spin {
  width: 100%;
  margin-top: 0;
}

/* Unavailable, and visibly so — but still a control: it keeps its place in the
 * tab order, it answers when pressed, and `aria-disabled` is what a screen
 * reader hears. `disabled` would take it out of reach of the very visitor who
 * most needs to be told why.
 *
 * Dimmed by opacity it read at about 2.2:1 — white on a washed-out red. A
 * control that still answers has to stay legible, so it changes colour instead
 * of fading: ink on paper, with an outline, which is what «not yet» looks like
 * rather than what «broken» looks like. */
.wheel-foot .wheel-spin[aria-disabled="true"] {
  background: var(--paper-2, #efe8dc);
  color: var(--ink-soft, #4a5478);
  border: 1.5px solid var(--line-2, rgba(20, 30, 74, 0.22));
  box-shadow: none;
  cursor: not-allowed;
}

.wheel-foot .wheel-spin[aria-busy="true"] {
  cursor: progress;
}

/* The live region. It carries a sentence a screen reader is meant to hear, so
 * it must not be `display:none` — that would take it out of the accessibility
 * tree along with the announcement. It is placed off-screen instead. */
.wheel-gate-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* An accepted lead that the endpoint had already seen. No prize is named here,
 * because none was drawn for it. */
.wheel-known {
  font-size: 0.98rem;
  color: var(--ink-soft, #4a5478);
  max-width: 30em;
  margin: 0 auto 1.2em;
  line-height: 1.55;
}

.wheel-rules {
  margin: 1.2em 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft, #4a5478);
  line-height: 1.55;
}

.wheel-rules a {
  white-space: nowrap;
  color: var(--blue, #314cb6);
}

.wheel-result .win-label {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft, #4a5478);
  font-weight: 600;
  margin: 0;
}

.wheel-result .prize {
  font-family: var(--display-font, "Comfortaa"), sans-serif;
  font-weight: 700;
  font-size: clamp(1.24rem, 1rem + 0.9vw, 1.62rem);
  color: var(--blue-deep, #2d4192);
  margin: 0.35em 0 0.3em;
  line-height: 1.25;
}

.wheel-result .prize-desc {
  font-size: 0.92rem;
  color: var(--ink-soft, #4a5478);
  max-width: 30em;
  margin: 0 auto 1.2em;
  line-height: 1.55;
}

.wheel-promo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7em;
  flex-wrap: wrap;
  margin: 0 0 0.9em;
}

.wheel-code {
  font-family: var(--display-font, "Comfortaa"), sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  padding: 0.45em 0.9em;
  border-radius: 12px;
  border: 1.5px dashed rgba(49, 76, 182, 0.45);
  background: rgba(49, 76, 182, 0.07);
}

.wheel-copy {
  border: 1px solid var(--line, rgba(20, 30, 74, 0.13));
  background: var(--paper-3, #fffdfa);
  color: var(--blue, #314cb6);
  border-radius: 999px;
  padding: 0.5em 1em;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.wheel-copied {
  font-size: 0.85rem;
  color: var(--ink-soft, #4a5478);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.wheel-copied[data-visible="true"] {
  opacity: 1;
}

/* The ask is a block, whatever the brand pack does with `.wheel-actions` —
 * which in the club's own pack is a wrapping flex row built for one button. */
.wheel-actions .wheel-ask {
  flex: 1 1 100%;
}

/* A telephone holds a wheel AND a form now. The disc gives up the room, because
 * the disc is the thing that can be smaller and still be a wheel — and because
 * a button below the fold is a button nobody presses. Two classes, so this wins
 * over the brand pack's own `.wheel-stage` whatever the load order. */
@media (max-width: 720px), (max-height: 860px) {
  /* 196px painted a 320-unit disc at 0.61 and turned a 15-unit prize into nine
   * pixels. The copy diet below the disc gave back four lines of small print;
   * they are spent here, on the object the dialog is about. */
  .wheel-dialog .wheel-stage {
    max-width: 238px;
    margin-top: 10px;
  }
  .wheel-dialog .wheel-card {
    padding: 18px 18px 20px;
  }
  .wheel-dialog .sub {
    font-size: 0.92rem;
  }
  .wheel-dialog .wheel-prizes {
    margin-top: 12px;
  }
  .wheel-dialog .wheel-actions {
    margin-top: 14px;
  }
  .wheel-dialog .wheel-ask {
    padding-top: 14px;
  }
}

/* A SHORT SCREEN. NOT A NARROW ONE.
 *
 * What runs out on a telephone is height, and the previous query mixed the two:
 * at 375×932 it applied the same diet as at 375×667 although nothing was
 * scrolling there. This one is about height alone, and it spends it in the
 * order the owner set — the supporting sentence first, then the gaps between
 * things, and never the three prize names or the size of the disc.
 *
 * The measured budget it is built against, at 375×812: the card may be 792px,
 * the foot with the button takes 86, the padding 36, so what is read has 670 to
 * stand in. Before this rule it asked for 752 and the button ended up at 849px
 * on an 812px screen. */
@media (max-height: 940px) {
  .wheel-dialog .wheel-card h2 {
    margin-top: 0.2em;
    margin-bottom: 0.3em;
  }
  .wheel-dialog .wheel-prizes {
    margin-top: 10px;
  }
  .wheel-dialog .wheel-stage {
    margin-top: 6px;
  }
  .wheel-dialog .wheel-actions {
    margin-top: 10px;
  }
  .wheel-dialog .wheel-ask {
    padding-top: 10px;
  }
  /* The brand pack's own field spacing, which is written for a page and not for
   * a dialog standing on 670px of telephone. */
  .wheel-dialog .wheel-ask .field {
    margin-top: 6px;
  }
  .wheel-dialog .wheel-ask .consent {
    margin-top: 10px;
  }
  .wheel-dialog .wheel-ask .consent-optional {
    margin-top: 8px;
    padding-top: 8px;
  }
  .wheel-dialog .wheel-rules {
    margin-top: 0.9em;
  }
}

/* THE SUPPORTING SENTENCE GOES LAST OF THE THINGS THAT GO, AND ONLY WHERE THE
 * TIGHTENED GAPS WERE NOT ENOUGH.
 *
 * «Оставьте телефон и крутите — подарок уедет вместе с заявкой» is said again by
 * the field label and by the button under it, so it is the cheapest 58px in the
 * card — but 58px bought where they are not needed is a sentence taken from the
 * visitor for nothing. The threshold is measured, not guessed: with the
 * sentence in place the read column asks for about 872px at 375, so it stays
 * wherever the dialog may be that tall, and steps aside below it.
 *
 * It is clipped rather than removed: it is the button's own description
 * (`aria-describedby`), and `display:none` would take that away from the one
 * visitor who cannot see the layout that replaced it. */
@media (max-height: 890px) {
  /* The last of the empty room, and it is empty room and not law: the ФЗ-38
   * line keeps its size — it was tried at 12px and bought eleven pixels that
   * still did not seat the second row, which is a smaller sentence for nothing.
   * What it loses is the gap above it and two pixels of the card's own foot. */
  .wheel-dialog .wheel-rules {
    margin-top: 0.7em;
  }
  .wheel-dialog .wheel-card {
    padding-bottom: 16px;
  }
  .wheel-dialog .wheel-card .sub {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}

/* Reduced motion: the result appears, the disc does not perform. The script
 * removes the transition as well, so nothing turns at all. */
@media (prefers-reduced-motion: reduce) {
  .wheel-card {
    animation: none;
  }
  [data-x30-wheel-rotor],
  .wheel-label {
    transition: none !important;
  }
}
