/* =========================================================================
   MIDA V!!!U eelvaade (preview-deck.js) — üks kaart korraga, voor = 10 kaarti.
   Kasutavad avaleht ja /mida-viiu. Sõltub base.css tokenitest.
   NB: lehe sektsioon peab väljuva kaardi jaoks kasutama overflow-x: clip.
   ========================================================================= */
.pvd {
  --pvd-c: #ff2fa8;
  --pvd-g: var(--grad-brand);
  /* päris kaardi nurgaraadius (~3,2% laiusest) */
  --pvd-r: 3.4% / 5.1%;
  position: relative;
  container-type: inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 620px;
  margin-inline: auto;
}

/* ---------- päis: kategooria + loendur ---------- */
.pvd__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}
.pvd__cat {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
  margin: 0;
}
.pvd-code {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--pvd-g, var(--grad-brand));
  color: #fff;
  font-family: var(--font-condensed);
  font-size: 1.08rem;
  line-height: 1;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 18px color-mix(in srgb, var(--pvd-c, #ff2fa8) 45%, transparent), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  transition: box-shadow 0.4s;
}
.pvd__name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.15;
}
.pvd__bonus {
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid currentColor;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pvd__bonus[data-bonus='plus'] {
  color: var(--ok);
  background: rgba(61, 255, 168, 0.08);
}
.pvd__bonus[data-bonus='minus'] {
  color: #ffb36b;
  background: rgba(255, 138, 28, 0.1);
}
.pvd__count {
  flex: none;
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--faint);
}
.pvd__count b {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--text);
}

/* ---------- edenemine (10 lõiku) ---------- */
.pvd__progress {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
}
.pvd__progress i {
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 0.35s, box-shadow 0.35s;
}
.pvd__progress i.is-done {
  background: rgba(255, 244, 251, 0.5);
}
.pvd__progress i.is-on {
  background: var(--pvd-g);
  box-shadow: 0 0 10px color-mix(in srgb, var(--pvd-c) 70%, transparent);
}
.pvd.is-end .pvd__progress i {
  background: var(--pink);
}

/* ---------- lava: pakk + kaart ---------- */
.pvd__stage {
  position: relative;
  aspect-ratio: 1074 / 720;
  margin: 4px 0 calc(7% + 4px);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.pvd__stage::before {
  /* värviline kuma kaardi taga (kaarditüübi värv) */
  content: '';
  position: absolute;
  inset: 8% 6% -4%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--pvd-c) 42%, transparent), transparent);
  filter: blur(26px);
  opacity: 0.85;
  transition: background 0.5s;
  pointer-events: none;
}
.pvd__shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -9%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.75), transparent);
  filter: blur(8px);
  pointer-events: none;
}
.pvd__pile {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pvd__pile-card {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--pvd-r);
  transform: translateY(calc(var(--i) * 3.4%)) scale(calc(1 - var(--i) * 0.05)) rotate(calc(var(--i) * -1.8deg));
  filter: brightness(calc(0.66 - var(--i) * 0.16));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  transition: transform 0.45s var(--ease-out);
}
.pvd__pile-img,
.pvd__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
.pvd__card,
.pvd__ghost {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--pvd-r);
  perspective: 1600px;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.pvd__ghost {
  z-index: 3;
  pointer-events: none;
}
.pvd__stage.is-dragging .pvd__card {
  cursor: grabbing;
}
.pvd__card:focus-visible {
  outline: none;
}
.pvd__card:focus-visible .pvd__face {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--pink-hot), 0 0 40px rgba(255, 47, 168, 0.6);
}
.pvd__inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.3, 1.35, 0.5, 1);
}
.pvd__card.is-flipped .pvd__inner {
  transform: rotateY(180deg);
}
.pvd__card.no-anim .pvd__inner {
  transition: none;
}
.pvd__face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--pvd-r);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 24px 50px -16px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.pvd__face--front {
  transform: rotateY(180deg);
}
/* „Pööra“ vihje — ainult enne esimest pööramist */
.pvd__tap {
  position: absolute;
  right: 4%;
  bottom: 6%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 10px;
  border-radius: 99px;
  background: rgba(7, 3, 10, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  transform: translateZ(1px);
  transition: opacity 0.3s;
  animation: pvd-tap 2.4s ease-in-out 1s infinite;
  pointer-events: none;
}
.pvd__tap .icon {
  width: 15px;
  height: 15px;
}
.pvd__card.is-flipped .pvd__tap,
.pvd.has-flipped .pvd__tap {
  opacity: 0;
  animation: none;
}
@keyframes pvd-tap {
  0%,
  60%,
  100% {
    transform: translateZ(1px) scale(1);
  }
  75% {
    transform: translateZ(1px) scale(1.08);
  }
}
.pvd__stage.is-shuffling .pvd__card {
  animation: pvd-riffle 0.65s var(--ease-out);
}
.pvd__stage.is-shuffling .pvd__pile-card {
  animation: pvd-riffle-pile 0.65s var(--ease-out);
}
@keyframes pvd-riffle {
  0% {
    transform: none;
  }
  35% {
    transform: translateY(10%) rotate(-7deg) scale(0.92);
  }
  65% {
    transform: translateY(-4%) rotate(4deg);
  }
}
@keyframes pvd-riffle-pile {
  40% {
    transform: translateX(calc(var(--i) * 12%)) rotate(calc(var(--i) * 6deg));
  }
}

/* ---------- vooru lõpp ---------- */
.pvd__end {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  padding: 5% 7%;
  border-radius: var(--pvd-r);
  border: 1px solid var(--line-strong);
  background: radial-gradient(80% 90% at 50% 0%, rgba(255, 47, 168, 0.42), transparent 70%), linear-gradient(160deg, #22071c, #0b0309);
  box-shadow: 0 24px 50px -16px rgba(0, 0, 0, 0.85), var(--glow);
  text-align: center;
}
.pvd__end[hidden] {
  display: none;
}
.pvd__end:focus {
  outline: none;
}
.pvd__end-kicker {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--pink-soft);
}
.pvd__end-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 5.4cqw, 1.7rem);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.pvd__end-title span {
  color: var(--pink-hot);
  text-shadow: var(--glow-text);
}
.pvd__end-text {
  margin: 2px 0 4px;
  max-width: 38ch;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--muted);
}
.pvd__end-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}
.pvd__end-btns .btn {
  min-height: 44px;
}
@container (max-width: 459px) {
  .pvd__end-text {
    display: none;
  }
  .pvd__end-btns .btn {
    padding-inline: 14px;
    font-size: 0.8rem;
  }
}

/* ---------- nupuriba ---------- */
.pvd__bar {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 12px;
}
.pvd__nav {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  transition: transform 0.25s var(--ease-spring), background 0.25s, opacity 0.25s, box-shadow 0.25s;
}
.pvd__nav .icon {
  width: 22px;
  height: 22px;
}
.pvd__nav--next {
  border-color: transparent;
  background: var(--pink);
  box-shadow: var(--glow-sm);
}
.pvd__nav:not(:disabled):hover {
  transform: scale(1.06);
  background: rgba(255, 47, 168, 0.25);
}
.pvd__nav--next:not(:disabled):hover {
  background: var(--pink-hot);
  box-shadow: var(--glow);
}
.pvd__nav:not(:disabled):active {
  transform: scale(0.94);
}
.pvd__nav:disabled {
  opacity: 0.3;
  cursor: default;
  box-shadow: none;
}
.pvd__nav:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}
.pvd__shuffle {
  justify-self: center;
  min-height: 48px;
  padding-inline: 22px;
}
.pvd__shuffle .icon {
  width: 18px;
  height: 18px;
}
.pvd__desc {
  margin: 0;
  min-height: 3em;
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
  text-wrap: pretty;
}

/* ---------- kaarditüüpide legend ---------- */
.pvd-legend {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pvd-legend__item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.012));
}
.pvd-legend__back {
  width: 88px;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5), 0 0 22px color-mix(in srgb, var(--pvd-c) 25%, transparent);
  transform: rotate(-4deg);
}
.pvd-legend__body {
  display: grid;
  gap: 4px;
}
.pvd-legend__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.pvd-legend__meta .pvd-code {
  min-width: 40px;
  height: 24px;
  font-size: 0.92rem;
}
.pvd-legend__name {
  margin: 2px 0 0;
  font-size: 1.05rem;
}
.pvd-legend__sub {
  font-family: var(--font-body);
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted);
}
.pvd-legend__text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
}

@media (max-width: 420px) {
  .pvd {
    gap: 10px;
  }
  .pvd__bar {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 10px;
  }
  .pvd__nav {
    width: 48px;
    height: 48px;
  }
  .pvd__name {
    font-size: 0.92rem;
  }
}

/* Telefonis: legend on rõhtne libistatav rida (vähem kõrgust, järgmine kaart piilub servast) */
@media (max-width: 699px) {
  .pvd-legend {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: min(80vw, 320px);
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    margin-inline: calc(var(--gutter) * -1);
    padding: 4px var(--gutter) 10px;
    scrollbar-width: none;
  }
  .pvd-legend::-webkit-scrollbar {
    display: none;
  }
  .pvd-legend__item {
    scroll-snap-align: start;
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-areas:
      'img  meta'
      'img  name'
      'text text';
    align-items: end;
    gap: 4px 12px;
    padding: 14px;
  }
  .pvd-legend__back {
    grid-area: img;
    width: 72px;
  }
  .pvd-legend__body {
    display: contents;
  }
  .pvd-legend__meta {
    grid-area: meta;
  }
  .pvd-legend__name {
    grid-area: name;
    align-self: start;
    margin: 0;
    font-size: 1rem;
  }
  .pvd-legend__text {
    grid-area: text;
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pvd__inner,
  .pvd__pile-card,
  .pvd__nav {
    transition: none;
  }
  .pvd__tap,
  .pvd__stage.is-shuffling .pvd__card,
  .pvd__stage.is-shuffling .pvd__pile-card {
    animation: none;
  }
}
.pvd__card[hidden] {
  display: none;
}
