/*
 * Limited-quantity tiered discounts (Black Friday) — the progress block inside
 * each eligible /off course card and the compact course-page badge beside the
 * breadcrumb. Black/red identity; follows html[data-theme] (dark default, light).
 * Loaded only on pages that render a tier widget.
 */
.dm-tiers {
  --tier-red: #e11d2a;
  --tier-red-deep: #b5121d;
  --tier-red-text: #ff4d58;
  --tier-red-tint: rgba(225, 29, 42, .14);
  --tier-red-line: rgba(225, 29, 42, .4);
  --tier-bg: #0b0b0d;
  --tier-surface: #141417;
  --tier-surface-2: #1c1c20;
  --tier-border: rgba(255, 255, 255, .1);
  --tier-text: #f4f4f6;
  --tier-muted: rgba(244, 244, 246, .66);
  --tier-track: rgba(255, 255, 255, .09);
  --tier-done: rgba(255, 255, 255, .38);
  font-family: inherit;
  color: var(--tier-text);
  box-sizing: border-box;
}
.dm-tiers *, .dm-tiers *::before, .dm-tiers *::after { box-sizing: border-box; }

html[data-theme="light"] .dm-tiers {
  --tier-red: #d7141f;
  --tier-red-deep: #a80f18;
  --tier-red-text: #c3111b;
  --tier-red-tint: rgba(215, 20, 31, .08);
  --tier-red-line: rgba(215, 20, 31, .3);
  --tier-bg: #ffffff;
  --tier-surface: #ffffff;
  --tier-surface-2: #f4f4f6;
  --tier-border: rgba(11, 11, 12, .12);
  --tier-text: #0b0b0c;
  --tier-muted: rgba(11, 11, 12, .62);
  --tier-track: rgba(11, 11, 12, .09);
  --tier-done: rgba(11, 11, 12, .35);
}

/* ---------- shared: meter ---------- */
.dm-tiers__meter {
  position: relative;
  display: block;
  height: .7em;
  border-radius: 999px;
  background: var(--tier-track);
  overflow: hidden;
}
.dm-tiers__fill {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--fill, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--tier-red-deep), var(--tier-red) 60%, #ff5a64);
  transition: width .9s cubic-bezier(.22, .8, .24, 1);
  animation: dmTierGrow 1.1s cubic-bezier(.22, .8, .24, 1) both;
}
.dm-tiers__fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, .35) 45%, transparent 70%);
  background-size: 220% 100%;
  animation: dmTierShine 2.6s linear infinite;
}
.is-live-update .dm-tiers__fill { animation: none; }
.dm-tiers__meter--idle { background: repeating-linear-gradient(-45deg, var(--tier-track) 0 .45em, transparent .45em .9em); }
.dm-tiers__meter--idle .dm-tiers__fill { display: none; }

@keyframes dmTierGrow { from { width: 0; } }
@keyframes dmTierShine { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@keyframes dmTierPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(225, 29, 42, .45); } 50% { box-shadow: 0 0 0 .35em rgba(225, 29, 42, 0); } }
@keyframes dmTierFlash { from { background-color: var(--tier-red-tint); } }

/* ---------- inside each /off course card: every tier, one bar each ---------- */
.dm-tiers--card {
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: .45em;
  margin-top: .9em;
  color: var(--tier-text);
  text-align: start;
  line-height: 1.65;
}
.dm-tiers--card + .dm-tiers--card { margin-top: .8em; }
.dm-tiers__course-name { font-size: .82em; font-weight: 800; color: var(--tier-muted); line-height: 1.5; }
.dm-tiers__intro { display: flex; flex-wrap: wrap; align-items: center; gap: .4em; margin: 0; font-size: .8em; font-weight: 700; color: var(--tier-muted); }
.dm-tiers__chip {
  padding: .1em .6em;
  border: 1px solid var(--tier-red-line);
  border-radius: 999px;
  color: var(--tier-red-text);
  font-size: .92em;
  font-weight: 800;
  white-space: nowrap;
}
.dm-tiers__list { list-style: none; display: flex; flex-direction: column; gap: .4em; margin: 0; padding: 0; }
.dm-tiers__tier {
  display: flex;
  flex-direction: column;
  gap: .3em;
  margin: 0;
  padding: .5em .7em .6em;
  border: 1px solid var(--tier-border);
  border-radius: .75em;
  background: var(--tier-surface-2);
  transition: border-color .3s ease, background-color .3s ease;
}
.dm-tiers__row { display: flex; align-items: center; justify-content: space-between; gap: .5em; }
.dm-tiers__pct { font-size: .88em; font-weight: 700; color: var(--tier-muted); white-space: nowrap; }
.dm-tiers__pct b { font-size: 1.3em; font-weight: 900; color: var(--tier-text); line-height: 1; }
.dm-tiers__badge {
  display: inline-flex;
  align-items: center;
  gap: .3em;
  padding: .12em .6em;
  border-radius: 999px;
  font-size: .72em;
  font-weight: 800;
  white-space: nowrap;
}
.dm-tiers__line { margin: 0; font-size: .9em; font-weight: 800; color: var(--tier-text); }
.dm-tiers__line b { color: var(--tier-red-text); font-weight: 900; }
.dm-tiers__meta { margin: 0; font-size: .76em; color: var(--tier-muted); }
.dm-tiers--card .dm-tiers__meter { height: .4em; }

/* active: the tier being sold right now */
.dm-tiers__tier.is-active {
  padding: .65em .8em .75em;
  border-color: var(--tier-red);
  background: linear-gradient(135deg, var(--tier-red-tint), transparent 70%), var(--tier-surface);
  box-shadow: 0 .4em 1.2em rgba(225, 29, 42, .16);
}
.dm-tiers__tier.is-active .dm-tiers__pct { color: var(--tier-text); }
.dm-tiers__tier.is-active .dm-tiers__pct b { font-size: 1.6em; color: var(--tier-red-text); }
.dm-tiers__tier.is-active .dm-tiers__badge { background: var(--tier-red); color: #fff; }
.dm-tiers__tier.is-active .dm-tiers__badge::before {
  content: "";
  width: .5em;
  height: .5em;
  border-radius: 50%;
  background: #fff;
  animation: dmTierBlink 1.4s ease-in-out infinite;
}
.dm-tiers__tier.is-active .dm-tiers__meter { height: .6em; }
.dm-tiers__tier.is-urgent { animation: dmTierPulse 1.8s ease-in-out infinite; }
.dm-tiers__tier.is-urgent .dm-tiers__line { color: var(--tier-red-text); }

/* completed: full bar, muted */
.dm-tiers__tier.is-full .dm-tiers__pct b { color: var(--tier-muted); text-decoration: line-through; text-decoration-color: var(--tier-red); text-decoration-thickness: .1em; }
.dm-tiers__tier.is-full .dm-tiers__badge { border: 1px solid var(--tier-border); color: var(--tier-muted); }
.dm-tiers__tier.is-full .dm-tiers__fill { background: var(--tier-done); }
.dm-tiers__tier.is-full .dm-tiers__fill::after { display: none; }

/* upcoming: what opens next, empty striped track */
.dm-tiers__tier.is-upcoming { border-style: dashed; background: transparent; }
.dm-tiers__tier.is-upcoming .dm-tiers__meter { background: repeating-linear-gradient(-45deg, var(--tier-track) 0 .45em, transparent .45em .9em); box-shadow: inset 0 0 0 1px var(--tier-track); }
.dm-tiers__tier.is-upcoming .dm-tiers__fill::after { display: none; }

.dm-tiers--card.is-soldout .dm-tiers__intro { color: var(--tier-text); }

/* one shared container for a card that offers several courses: the percent
   once per tier, then one capacity line + bar per course (never combined) */
.dm-tiers__tier--shared { gap: .45em; }
.dm-tiers__sub { display: flex; flex-direction: column; gap: .25em; min-width: 0; }
.dm-tiers__sub + .dm-tiers__sub { padding-top: .5em; border-top: 1px dashed var(--tier-border); }
.dm-tiers__sub-label { display: flex; align-items: center; gap: .45em; margin: 0; font-size: .8em; font-weight: 700; color: var(--tier-text); }
.dm-tiers__sub-label::before { content: ""; flex: none; width: .3em; height: 1em; border-radius: 999px; background: var(--tier-red); }
.dm-tiers__sub-status { margin: 0; font-size: .76em; font-weight: 700; color: var(--tier-muted); }
.dm-tiers__sub-status b { color: var(--tier-red-text); font-weight: 900; }
.dm-tiers__sub-status span:last-child { display: inline-block; margin-inline-start: .5em; font-weight: 500; color: var(--tier-muted); }
.dm-tiers__sub.is-active .dm-tiers__sub-status { color: var(--tier-text); }
.dm-tiers__sub.is-active .dm-tiers__meter { height: .55em; }
.dm-tiers__sub.is-urgent .dm-tiers__sub-status { color: var(--tier-red-text); }
.dm-tiers__sub.is-full .dm-tiers__sub-label::before, .dm-tiers__sub.is-upcoming .dm-tiers__sub-label::before { background: var(--tier-done); }
.dm-tiers__sub.is-full .dm-tiers__sub-label { color: var(--tier-muted); }
.dm-tiers__sub.is-full .dm-tiers__fill { background: var(--tier-done); }
.dm-tiers__sub.is-full .dm-tiers__fill::after, .dm-tiers__sub.is-upcoming .dm-tiers__fill::after { display: none; }
.dm-tiers__sub.is-upcoming .dm-tiers__meter { height: .4em; background: repeating-linear-gradient(-45deg, var(--tier-track) 0 .45em, transparent .45em .9em); box-shadow: inset 0 0 0 1px var(--tier-track); }
.dm-tiers--card.is-live-update .dm-tiers__tier.is-active { animation: dmTierFlash 1.2s ease-out; }
@keyframes dmTierBlink { 50% { opacity: .35; } }

/* ---------- compact badge beside the course breadcrumb ---------- */
.dm-tiers--compact {
  font-size: 13px !important;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3em .5em;
  max-width: 100%;
  min-width: 0;
  margin-inline-start: auto;
  padding: .35em .75em;
  border: 1px solid var(--tier-red-line);
  border-radius: 999px;
  background: var(--tier-bg);
  color: var(--tier-text);
  line-height: 1.6;
  box-shadow: 0 .3em .9em rgba(0, 0, 0, .18);
}
.dm-tiers--compact .dm-tiers__text { min-width: 0; }
.dm-tiers--compact .dm-tiers__text b { color: var(--tier-red-text); font-weight: 900; }
.dm-tiers--compact .dm-tiers__brand { padding: .05em .45em; margin-inline-end: .2em; border-radius: .35em; background: var(--tier-red); color: #fff !important; font-size: .7em; letter-spacing: .04em; }
.dm-tiers--compact .dm-tiers__meter--mini { flex: 1 1 5em; min-width: 5em; max-width: 9em; height: .4em; }
.dm-tiers--compact.is-urgent { border-color: var(--tier-red); animation: dmTierPulse 1.8s ease-in-out infinite; }
.dm-tiers--compact.is-live-update { animation: dmTierFlash 1.2s ease-out; }

/* The badge sits at the inline end (left in RTL) of the breadcrumb row and
   drops to its own line on narrow screens without pushing the crumbs. */
.dm-tiers-crumb-row { flex-wrap: wrap; row-gap: 8px; }
/* The crumb row only hugs its content; with the badge it spans the whole
   breadcrumb banner so the badge reaches the banner's left edge. */
.breadcrumb > .breadcrumb-Content.dm-tiers-crumb-row { flex: 1 1 auto; width: 100%; min-width: 0; }
.dm-tiers--compact .dm-tiers__brand { unicode-bidi: isolate; }
.dm-tiers-crumb-row > .breadcrumb-List { min-width: 0; }
.ail-top.dm-tiers-crumb-row { display: flex; align-items: center; gap: 8px 16px; }
@media (max-width: 767.98px) {
  .dm-tiers--compact { margin-inline-start: 0; border-radius: .9em; width: 100%; }
  .dm-tiers--compact .dm-tiers__meter--mini { max-width: none; }
  .dm-tiers--card { font-size: 13.5px; }
  .dm-tiers__tier { padding: .45em .6em .55em; }
  .dm-tiers__tier.is-active { padding: .6em .7em .7em; }
}

@media (prefers-reduced-motion: reduce) {
  .dm-tiers__fill, .dm-tiers__tier { transition: none; }
  .dm-tiers__fill, .dm-tiers__fill::after, .dm-tiers__tier.is-urgent, .dm-tiers--card.is-live-update .dm-tiers__tier.is-active, .dm-tiers__tier.is-active .dm-tiers__badge::before, .dm-tiers--compact.is-urgent, .dm-tiers--compact.is-live-update { animation: none; }
}
