/* Everyday effects: the undo snackbar with its countdown ring (undo-toast.mjs),
   the weekly streak chip, card and celebration (rewards-streak.mjs) and the
   invite flight and new-friend line (invite-flight.mjs). Self-themed: both
   palettes are set here, so no generated light twin is needed. Buttons answer
   the app-wide transparent-button reset in styles.css with two classes and
   !important. Logical properties keep Arabic mirrored. */
:root {
  --bh-fx-ink: #f4eff7;
  --bh-fx-muted: #a99fb0;
  --bh-fx-surface: rgba(26,21,32,.95);
  --bh-fx-raised: rgba(255,255,255,.06);
  --bh-fx-line: rgba(255,255,255,.11);
  --bh-fx-accent: #ff6aae;
  --bh-fx-accent-strong: #f04491;
  --bh-fx-accent-soft: rgba(240,68,145,.17);
  --bh-fx-accent-hover: rgba(240,68,145,.28);
  --bh-fx-flame-outer: #ff6b4a;
  --bh-fx-flame-inner: #ffd166;
  --bh-fx-flame-text: #ffb38f;
  --bh-fx-flame-soft: rgba(255,107,74,.13);
  --bh-fx-flame-line: rgba(255,140,100,.32);
  --bh-fx-dot: rgba(255,255,255,.12);
  --bh-fx-calm: #f3c27a;
  --bh-fx-plane-fill: rgba(255,106,174,.22);
  --bh-fx-shadow: 0 18px 50px rgba(0,0,0,.48), 0 0 0 1px rgba(255,255,255,.035);
}
html[data-theme="light"] {
  --bh-fx-ink: #2b2230;
  --bh-fx-muted: #6c6172;
  --bh-fx-surface: rgba(255,255,255,.98);
  --bh-fx-raised: #f6eff4;
  --bh-fx-line: rgba(84,37,65,.14);
  --bh-fx-accent: #bd2c6c;
  --bh-fx-accent-strong: #e0337f;
  --bh-fx-accent-soft: #fde3ef;
  --bh-fx-accent-hover: #f9cfe2;
  --bh-fx-flame-outer: #f0592b;
  --bh-fx-flame-inner: #ffbe2e;
  --bh-fx-flame-text: #b2461d;
  --bh-fx-flame-soft: #fff0e8;
  --bh-fx-flame-line: #f6c7b3;
  --bh-fx-dot: rgba(84,37,65,.13);
  --bh-fx-calm: #9a5b0c;
  --bh-fx-plane-fill: #ffe0ee;
  --bh-fx-shadow: 0 16px 40px rgba(84,37,65,.17), 0 0 0 1px rgba(84,37,65,.04);
}
.bh-undo-live, .bh-invite-live {
  position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---- Undo with countdown ------------------------------------------------ */
.bh-undo-region {
  position: fixed; z-index: 260; inset-inline: 0; bottom: max(22px, env(safe-area-inset-bottom));
  display: grid; justify-items: center; gap: 8px; padding-inline: 16px; pointer-events: none;
}
.bh-undo-toast {
  pointer-events: auto; box-sizing: border-box; display: flex; align-items: center; gap: 12px;
  width: min(470px, 100%); min-height: 54px; padding-block: 8px; padding-inline: 12px 8px;
  border: 1px solid var(--bh-fx-line); border-radius: 16px; background: var(--bh-fx-surface);
  color: var(--bh-fx-ink); box-shadow: var(--bh-fx-shadow); font-size: 13.5px;
  -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
  animation: bh-undo-in .28s cubic-bezier(.2,.9,.25,1.15) both;
}
.bh-undo-toast[data-closing] { animation: bh-fx-leave .2s ease both; pointer-events: none; }
.bh-undo-toast[data-busy] { opacity: .78; }
.bh-undo-ring { position: relative; flex: none; display: grid; place-items: center; width: 32px; height: 32px; }
.bh-undo-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.bh-undo-ring circle { fill: none; stroke-width: 2.6; }
.bh-undo-ring-track { stroke: var(--bh-fx-dot); }
.bh-undo-ring-time { stroke: var(--bh-fx-accent); stroke-linecap: round; transition: stroke-dashoffset .2s linear; }
.bh-undo-toast[data-paused] .bh-undo-ring-time { stroke: var(--bh-fx-muted); }
.bh-undo-ring b { position: relative; color: var(--bh-fx-ink); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.bh-undo-message { flex: 1 1 auto; min-width: 0; margin: 0; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.bh-undo-region .bh-undo-toast .bh-undo-button {
  flex: none; min-height: 38px; margin: 0; padding: 0 16px; border: 1px solid transparent !important; border-radius: 11px;
  background: var(--bh-fx-accent-soft) !important; color: var(--bh-fx-accent); font: inherit; font-size: 13.5px; font-weight: 800;
  cursor: pointer; transition: background-color .15s ease;
}
.bh-undo-region .bh-undo-toast .bh-undo-button:hover { background: var(--bh-fx-accent-hover) !important; }
.bh-undo-region .bh-undo-toast .bh-undo-close {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; margin: 0; padding: 0;
  border: 1px solid transparent !important; border-radius: 10px; background: transparent !important;
  color: var(--bh-fx-muted); font: inherit; font-size: 19px; line-height: 1; cursor: pointer;
}
.bh-undo-region .bh-undo-toast .bh-undo-close:hover { background: var(--bh-fx-raised) !important; color: var(--bh-fx-ink); }
.bh-undo-region .bh-undo-toast :is(.bh-undo-button, .bh-undo-close):focus-visible { outline: 2px solid var(--bh-fx-accent) !important; outline-offset: 2px; }
.bh-undo-region .bh-undo-toast :is(.bh-undo-button, .bh-undo-close):disabled { cursor: progress; }
/* Other messages rise above the snackbar instead of covering it. */
.toast-region { transition: translate .2s ease; }
body:has(.bh-undo-toast:not([data-closing])) .toast-region { translate: 0 -70px; }
@media (max-width: 760px) {
  .bh-undo-region { bottom: max(12px, env(safe-area-inset-bottom)); padding-inline: 12px; }
  .bh-undo-toast { gap: 8px; padding-inline: 10px 6px; font-size: 13px; }
  .bh-undo-region .bh-undo-toast .bh-undo-button { padding: 0 12px; }
}
@keyframes bh-undo-in { from { opacity: 0; transform: translateY(18px) scale(.97); } }
@keyframes bh-fx-leave { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---- Weekly streak: chip in the top bar ---------------------------------- */
.responsive-preview-control .bh-streak-chip {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 4px;
  min-height: 30px; margin: 0; padding-block: 0; padding-inline: 7px 10px;
  border: 1px solid var(--bh-fx-flame-line) !important; border-radius: 999px; background: var(--bh-fx-flame-soft) !important;
  color: var(--bh-fx-ink); font: inherit; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums;
  line-height: 1; white-space: nowrap; cursor: pointer;
}
.responsive-preview-control .bh-streak-chip[hidden] { display: none !important; }
.responsive-preview-control .bh-streak-chip:hover { border-color: var(--bh-fx-flame-outer) !important; }
.responsive-preview-control .bh-streak-chip:focus-visible { outline: 2px solid var(--bh-fx-flame-outer) !important; outline-offset: 2px; }
.responsive-preview-control .bh-streak-chip[data-streak-state="risk"] { border-style: dashed !important; background: transparent !important; color: var(--bh-fx-muted); }
.responsive-preview-control .bh-streak-chip.is-celebrating {
  animation: bh-streak-pop .75s cubic-bezier(.2,1.5,.4,1) both;
  box-shadow: 0 0 0 4px var(--bh-fx-flame-soft), 0 0 22px rgba(255,107,74,.5) !important;
}
.bh-streak-flame { flex: none; width: 15px; height: 15px; overflow: visible; }
:is(.bh-streak-flame, .bh-streak-badge-flame, .bh-streak-bubble-flame) .bh-streak-flame-outer { fill: var(--bh-fx-flame-outer); }
:is(.bh-streak-flame, .bh-streak-badge-flame, .bh-streak-bubble-flame) .bh-streak-flame-inner { fill: var(--bh-fx-flame-inner); }
.bh-streak-chip[data-streak-state="risk"] .bh-streak-flame-outer { fill: none; stroke: var(--bh-fx-flame-outer); stroke-width: 1.7; }
.bh-streak-chip[data-streak-state="risk"] .bh-streak-flame-inner { fill: none; }
.bh-streak-chip.is-celebrating .bh-streak-flame { transform-origin: 50% 90%; animation: bh-streak-flicker .45s ease-in-out 4; }
.bh-streak-embers { position: fixed; z-index: 275; width: 0; height: 0; pointer-events: none; }
.bh-streak-embers i {
  position: absolute; left: 0; top: 0; width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle, var(--bh-fx-flame-inner), var(--bh-fx-flame-outer) 72%); font-style: normal; opacity: 0;
}
.bh-streak-embers i:not(:empty) { width: auto; height: auto; background: none; color: var(--bh-fx-accent); font-size: 12px; line-height: 1; }
.bh-streak-bubble {
  position: fixed; z-index: 275; box-sizing: border-box; display: grid; grid-template-columns: auto minmax(0, 1fr);
  column-gap: 10px; align-items: center; max-width: min(300px, calc(100vw - 24px)); padding: 10px 16px 10px 12px;
  padding-inline: 12px 16px; border: 1px solid var(--bh-fx-flame-line); border-radius: 14px; background: var(--bh-fx-surface);
  color: var(--bh-fx-ink); box-shadow: var(--bh-fx-shadow); pointer-events: none;
  animation: bh-streak-bubble-in .34s cubic-bezier(.2,1.35,.4,1) both;
}
.bh-streak-bubble::before {
  content: ""; position: absolute; top: -6px; left: var(--bh-streak-tip, 50%); width: 10px; height: 10px; margin-left: -5px;
  border-top: 1px solid var(--bh-fx-flame-line); border-left: 1px solid var(--bh-fx-flame-line);
  background: var(--bh-fx-surface); transform: rotate(45deg);
}
.bh-streak-bubble[data-leaving] { animation: bh-fx-leave .25s ease both; }
.bh-streak-bubble-flame { grid-row: span 2; width: 30px; height: 30px; }
.bh-streak-bubble span { color: var(--bh-fx-flame-text); font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.bh-streak-bubble strong { font-size: 14.5px; letter-spacing: -.01em; overflow-wrap: anywhere; }

/* ---- Weekly streak: card on the Rewards overview ------------------------- */
.bh-streak-card {
  position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center; gap: 18px;
}
.bh-streak-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255,209,102,.16) 48%, transparent 66%);
}
.bh-streak-badge {
  position: relative; display: grid; place-items: center; width: 66px; height: 66px; border-radius: 21px;
  background: var(--bh-fx-flame-soft); box-shadow: inset 0 0 0 1px var(--bh-fx-flame-line);
}
.bh-streak-badge-flame { width: 46px; height: 46px; overflow: visible; filter: drop-shadow(0 4px 12px rgba(255,107,74,.35)); }
.bh-streak-badge b {
  position: absolute; inset-inline: 0; bottom: 13px; color: #3a1405; font-size: 14px; font-weight: 900;
  text-align: center; font-variant-numeric: tabular-nums; line-height: 1;
}
.bh-streak-card[data-streak-state="start"] .bh-streak-badge { background: var(--bh-fx-raised); box-shadow: inset 0 0 0 1px var(--bh-fx-line); }
.bh-streak-card[data-streak-state="start"] .bh-streak-badge-flame { filter: none; }
.bh-streak-card[data-streak-state="start"] .bh-streak-badge-flame .bh-streak-flame-outer { fill: var(--bh-fx-dot); }
.bh-streak-card[data-streak-state="start"] .bh-streak-badge-flame .bh-streak-flame-inner { fill: var(--bh-fx-dot); }
.bh-streak-card[data-streak-state="start"] .bh-streak-badge b { color: var(--bh-fx-muted); }
.bh-streak-copy { display: grid; gap: 4px; min-width: 0; }
.bh-streak-eyebrow { color: var(--bh-fx-flame-text); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.bh-streak-title { color: var(--bh-fx-ink); font-size: 21px; letter-spacing: -.025em; line-height: 1.2; overflow-wrap: anywhere; }
.bh-streak-line { margin: 0; color: var(--bh-fx-muted); font-size: 12.5px; line-height: 1.45; }
.bh-streak-card[data-streak-state="risk"] .bh-streak-line { color: var(--bh-fx-calm); font-weight: 700; }
.bh-streak-side { display: grid; justify-items: end; gap: 9px; }
.bh-streak-weeks { display: flex; gap: 6px; }
.bh-streak-week { display: block; width: 13px; height: 13px; border-radius: 50%; background: var(--bh-fx-dot); }
.bh-streak-week.lit { background: linear-gradient(160deg, var(--bh-fx-flame-inner), var(--bh-fx-flame-outer)); box-shadow: 0 0 9px rgba(255,107,74,.4); }
.bh-streak-week.now:not(.lit) { background: transparent; box-shadow: inset 0 0 0 2px var(--bh-fx-dot); }
.bh-streak-card[data-streak-state="risk"] .bh-streak-week.now { box-shadow: inset 0 0 0 2px var(--bh-fx-flame-outer); }
.bh-streak-best { color: var(--bh-fx-muted); font-size: 11.5px; font-weight: 700; }
.bh-streak-card.is-celebrating .bh-streak-badge { animation: bh-streak-pop .8s cubic-bezier(.2,1.5,.4,1) both; }
.bh-streak-card.is-celebrating .bh-streak-badge-flame { transform-origin: 50% 90%; animation: bh-streak-flicker .45s ease-in-out 4; }
.bh-streak-card.is-celebrating .bh-streak-week.lit { animation: bh-streak-dot .55s cubic-bezier(.2,1.6,.4,1) both; animation-delay: calc(var(--bh-streak-i, 0) * 70ms); }
.bh-streak-card.is-celebrating::after { animation: bh-streak-sheen 1.4s ease .2s both; }
@media (max-width: 640px) {
  .bh-streak-card { grid-template-columns: auto minmax(0, 1fr); gap: 12px 14px; }
  .bh-streak-side { grid-column: 1 / -1; justify-items: start; }
  .bh-streak-badge { width: 58px; height: 58px; border-radius: 18px; }
  .bh-streak-badge-flame { width: 40px; height: 40px; }
  .bh-streak-badge b { bottom: 11px; font-size: 13px; }
  .bh-streak-title { font-size: 18px; }
}
@keyframes bh-streak-pop { 0% { transform: scale(.7); } 55% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes bh-streak-flicker { 0%, 100% { transform: scale(1, 1) rotate(0); } 40% { transform: scale(.94, 1.1) rotate(-3deg); } 70% { transform: scale(1.04, .96) rotate(2deg); } }
@keyframes bh-streak-dot { 0% { transform: scale(.3); opacity: .3; } 100% { transform: scale(1); opacity: 1; } }
@keyframes bh-streak-sheen { 0% { opacity: 1; transform: translateX(-60%); } 100% { opacity: 0; transform: translateX(60%); } }
@keyframes bh-streak-bubble-in { from { opacity: 0; transform: translateY(-8px) scale(.94); } }

/* ---- Invite a friend --------------------------------------------------- */
.bh-invite-flight { position: fixed; z-index: 280; width: 0; height: 0; pointer-events: none; }
.bh-invite-plane { position: absolute; left: 0; top: 0; width: 30px; height: 30px; color: var(--bh-fx-accent); opacity: 0; filter: drop-shadow(0 5px 10px rgba(240,68,145,.4)); }
.bh-invite-plane svg { display: block; width: 100%; height: 100%; overflow: visible; fill: var(--bh-fx-plane-fill); stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.bh-invite-flight i { position: absolute; left: 0; top: 0; color: var(--bh-fx-accent); font-size: 13px; font-style: normal; line-height: 1; opacity: 0; }
.bh-invite-burst i { font-size: 15px; }
[data-invite-sent] .bh-invite-check { display: inline-block; margin-inline-end: 6px; font-weight: 900; }
.bh-invite-joined {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 12px;
  border-radius: 12px; background: var(--bh-fx-accent-soft); box-shadow: inset 0 0 0 1px var(--bh-fx-line);
  color: var(--bh-fx-ink); font-size: 13px; font-weight: 750; line-height: 1.4;
}
.bh-invite-joined-mark {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--bh-fx-accent-strong); color: #fff; font-size: 13px;
}
.bh-invite-joined.is-new { animation: bh-invite-in .5s cubic-bezier(.2,1.35,.4,1) both; }
.bh-invite-joined.is-new .bh-invite-joined-mark { animation: bh-invite-beat .9s ease .35s 2; }
.bh-invite-counting { color: var(--bh-fx-accent) !important; }
@keyframes bh-invite-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
@keyframes bh-invite-beat { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.22); } 60% { transform: scale(.96); } }

/* Reduced motion: every state shows, nothing moves. */
@media (prefers-reduced-motion: reduce) {
  .bh-undo-toast, .bh-undo-toast[data-closing], .bh-streak-bubble, .bh-streak-bubble[data-leaving],
  .responsive-preview-control .bh-streak-chip.is-celebrating, .bh-streak-chip.is-celebrating .bh-streak-flame,
  .bh-streak-card.is-celebrating .bh-streak-badge, .bh-streak-card.is-celebrating .bh-streak-badge-flame,
  .bh-streak-card.is-celebrating .bh-streak-week.lit, .bh-streak-card.is-celebrating::after,
  .bh-invite-joined.is-new, .bh-invite-joined.is-new .bh-invite-joined-mark { animation: none !important; }
  .bh-undo-ring-time, .toast-region { transition: none !important; }
  .bh-streak-embers, .bh-invite-flight { display: none !important; }
}
