/* Bilet karnetu (inc/bilet.php, PROJEKT §5.3, PLAN Task 20).
   Ładowany jawnie w inc/enqueue.php: strefa /karnet/{id}/{token}/, podziękowanie
   po zapisie i konto /konto/. Tylko tokeny v2 (--c-*, --t-*, --s-*, --r-*) i własne
   --ajb-* skopiowane z --ajk-* (konto-woda.css), żeby bilet wyglądał tak samo
   także poza kontem, gdzie konto-woda.css się nie ładuje.
   Stan nigdy tylko kolorem: słowo zawsze, „do zapłaty” ma dodatkowo przerywaną ramkę.
   Efekt „wow” (.is-wow, skrypt w linii aj_ticket_wow_script w inc/bilet.php): bursztyn na morski, znaczek „Opłacone”,
   fala i 5 bąbelków, około 1 s, raz na karnet; przy prefers-reduced-motion wyłączony. */

.ajb-bilet {
  --ajb-water: color-mix(in srgb, var(--c-brand-aqua-2) 20%, var(--c-bg));
  --ajb-water-line: color-mix(in srgb, var(--c-brand-aqua) 22%, var(--c-line));
  --ajb-water-2: color-mix(in srgb, var(--c-brand-aqua-2) 40%, var(--c-bg));
  --ajb-wave-h: 72px;
  --ajb-wave-w: 300px;
  --ajb-wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 150 600 160' preserveAspectRatio='none'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' vector-effect='non-scaling-stroke'%3E%3Cpath vector-effect='non-scaling-stroke' stroke-opacity='.55' d='M0 214c120 0 180-46 300-46s180 46 300 46'/%3E%3Cpath vector-effect='non-scaling-stroke' stroke-opacity='.33' d='M0 254c120 0 180-46 300-46s180 46 300 46'/%3E%3Cpath vector-effect='non-scaling-stroke' stroke-opacity='.17' d='M0 294c120 0 180-46 300-46s180 46 300 46'/%3E%3C/g%3E%3C/svg%3E");
  --ajb-accent: var(--c-fg);
  --ajb-bg: var(--ajb-water);
  --ajb-line: var(--ajb-water-line);

  position: relative;
  overflow: hidden;
  isolation: isolate;
  margin: 0;
  padding: var(--s-5);
  border: 1px solid var(--ajb-line);
  border-radius: var(--r-md);
  background: var(--ajb-bg);
  color: var(--c-fg);
  font-size: var(--t-ui);
  line-height: 1.45;
}

.ajb-list {
  display: grid;
  gap: var(--s-4);
  margin: 0 0 var(--s-6);
}

.ajb-bilet.is-paid {
  --ajb-accent: var(--c-brand-teal);
  --ajb-line: color-mix(in srgb, var(--c-brand-teal) 30%, var(--ajb-water-line));
}

.ajb-bilet.is-due {
  --ajb-accent: var(--c-warn);
  --ajb-bg: var(--c-warn-bg);
  --ajb-line: var(--c-warn);
  border-style: dashed;
  border-width: 1.5px;
}

.ajb-bilet.is-off {
  --ajb-bg: var(--c-bg-2);
  --ajb-line: var(--c-line);
  --ajb-accent: var(--c-fg-2);
}

/* Elementy z dwiema klasami (.ajb-bilet .ajb__x): arkusze Woo na podziękowaniu
   ustawiają marginesy akapitów i list, a bilet ma wyglądać wszędzie tak samo. */

/* Fala z konta „Woda”: nisko, w prawym dolnym rogu, kolor z akcentu. */
.ajb__wave {
  position: absolute;
  z-index: -1;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--ajb-wave-h);
  background-color: var(--ajb-accent);
  -webkit-mask: var(--ajb-wave) repeat-x 0 100% / var(--ajb-wave-w) 100%;
  mask: var(--ajb-wave) repeat-x 0 100% / var(--ajb-wave-w) 100%;
  opacity: 0.16;
  pointer-events: none;
}

.ajb-bilet .ajb__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
}

.ajb-bilet .ajb__k {
  margin: 0;
  color: var(--c-fg-2);
  font-size: var(--t-meta);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ajb__stamp,
.ajb__chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--s-1);
  padding: 2px var(--s-2);
  border: 1px solid currentColor;
  border-radius: var(--r-pill);
  font-size: var(--t-meta);
  font-weight: 600;
  white-space: nowrap;
}

.ajb__stamp {
  border-color: var(--c-brand-teal);
  background: var(--c-brand-teal);
  color: var(--c-bg);
}

.ajb__chip {
  color: var(--ajb-accent);
}

.ajb-bilet.is-due .ajb__chip {
  border-style: dashed;
}

.ajb__check path {
  stroke-dasharray: 24;
  stroke-dashoffset: 0;
}

.ajb-bilet .ajb__who {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--s-2);
  margin: var(--s-2) 0 0;
}

.ajb__who b {
  font-size: var(--t-h3);
  font-weight: 600;
}

.ajb__grp {
  color: var(--c-fg-2);
}

/* Kropki dat: odbyte pełne, najbliższe z obwódką, zaplanowane puste, wolne przekreślone. */
.ajb-bilet .ajb__dots {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-4);
  margin: var(--s-4) 0 0;
  padding: 0;
  list-style: none;
}

.ajb-bilet .ajb__dot {
  display: grid;
  justify-items: center;
  gap: var(--s-1);
  min-width: 40px;
  color: var(--c-fg-2);
  font-size: var(--t-meta);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.ajb__pt {
  width: 14px;
  height: 14px;
  border: 2px solid var(--ajb-accent);
  border-radius: var(--r-pill);
  background: transparent;
}

.ajb__dot--past .ajb__pt {
  background: var(--ajb-accent);
  opacity: 0.55;
}

.ajb-bilet .ajb__dot--next {
  color: var(--c-fg);
  font-weight: 600;
}

.ajb__dot--next .ajb__pt {
  background: var(--ajb-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ajb-accent) 18%, transparent);
}

.ajb__dot--off .ajb__pt {
  border-style: dashed;
  border-color: var(--c-fg-3);
  background: linear-gradient(135deg, transparent 44%, var(--c-fg-3) 44% 56%, transparent 56%);
}

.ajb__dot--makeup .ajb__pt {
  border-style: dotted;
}

.ajb__dot.is-absent .ajb__pt {
  border-color: var(--c-fg-3);
  background: transparent;
}

.ajb__why {
  max-width: 6.5em;
  color: var(--c-fg-3);
  font-size: 0.75rem;
  line-height: 1.2;
}

.ajb-bilet .ajb__state {
  margin: var(--s-4) 0 0;
  color: var(--ajb-accent);
  font-size: var(--t-h3);
  font-weight: 700;
  line-height: 1.3;
}

.ajb-bilet .ajb__next {
  margin: var(--s-1) 0 0;
  color: var(--c-fg);
}

.ajb__next span {
  display: block;
  color: var(--c-fg-2);
  font-size: var(--t-meta);
}

.ajb-bilet .ajb__acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  margin: var(--s-4) 0 0;
}

.ajb__cta {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s-4);
  border-radius: var(--r-sm);
  background: var(--c-fg);
  color: var(--c-bg);
  font-weight: 600;
  text-decoration: none;
}

.ajb__cta:hover {
  background: var(--c-fg-2);
  color: var(--c-bg);
}

.ajb__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--c-fg);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ajb__cta:focus-visible,
.ajb__link:focus-visible {
  outline: 2px solid var(--c-fg);
  outline-offset: 2px;
}

.ajb__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Bąbelki: tylko w czasie efektu. */
.ajb__bubbles {
  position: absolute;
  z-index: -1;
  inset: auto 0 0 0;
  height: 100%;
  pointer-events: none;
}

.ajb__bubbles i {
  position: absolute;
  bottom: 8px;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--c-brand-teal);
  border-radius: var(--r-pill);
  opacity: 0;
}

.ajb__bubbles i:nth-child(1) { left: 12%; }
.ajb__bubbles i:nth-child(2) { left: 30%; width: 6px; height: 6px; }
.ajb__bubbles i:nth-child(3) { left: 52%; width: 10px; height: 10px; }
.ajb__bubbles i:nth-child(4) { left: 71%; width: 6px; height: 6px; }
.ajb__bubbles i:nth-child(5) { left: 88%; }

@media (min-width: 768px) {
  .ajb-bilet {
    --ajb-wave-h: 96px;
    --ajb-wave-w: 600px;
    padding: var(--s-6);
  }
}

/* ---------- Efekt „wow” (raz na karnet) ---------- */

.ajb-bilet.is-wow {
  animation: ajb-tint 1s ease-out both;
}

.ajb-bilet.is-wow .ajb__state {
  animation: ajb-ink 1s ease-out both;
}

.ajb-bilet.is-wow .ajb__stamp {
  animation: ajb-stamp 0.45s 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.ajb-bilet.is-wow .ajb__check path {
  animation: ajb-draw 0.4s 0.55s ease-out both;
}

.ajb-bilet.is-wow .ajb__wave {
  animation: ajb-wave 1s ease-out both;
}

.ajb-bilet.is-wow .ajb__bubbles i {
  animation: ajb-bubble 0.9s ease-out both;
}

.ajb-bilet.is-wow .ajb__bubbles i:nth-child(2) { animation-delay: 0.08s; }
.ajb-bilet.is-wow .ajb__bubbles i:nth-child(3) { animation-delay: 0.16s; }
.ajb-bilet.is-wow .ajb__bubbles i:nth-child(4) { animation-delay: 0.04s; }
.ajb-bilet.is-wow .ajb__bubbles i:nth-child(5) { animation-delay: 0.12s; }

@keyframes ajb-tint {
  from {
    border-color: var(--c-warn);
    background-color: var(--c-warn-bg);
  }
}

@keyframes ajb-ink {
  from {
    color: var(--c-warn);
  }
}

@keyframes ajb-stamp {
  from {
    opacity: 0;
    transform: scale(1.5) rotate(-8deg);
  }
}

@keyframes ajb-draw {
  from {
    stroke-dashoffset: 24;
  }
}

/* Fala przesuwa się o jeden okres maski (kafel bez szwu, repeat-x). */
@keyframes ajb-wave {
  from {
    opacity: 0.4;
    -webkit-mask-position: calc(-1 * var(--ajb-wave-w)) 100%;
    mask-position: calc(-1 * var(--ajb-wave-w)) 100%;
  }
}

@keyframes ajb-bubble {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.6);
  }
  30% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translateY(-64px) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ajb-bilet.is-wow,
  .ajb-bilet.is-wow * {
    animation: none !important;
  }
}
