/* ── Ko-Fi theme tokens — override per-site to match brand ── */
:root {
  --kofi-acc:  #6366f1;          /* primary accent */
  --kofi-acc2: #818cf8;          /* lighter accent  */
  --kofi-acc3: #a78bfa;          /* purple accent   */
  --kofi-r1:   99,102,241;       /* rgb of --kofi-acc  */
  --kofi-r2:   129,140,248;      /* rgb of --kofi-acc2 */
  --kofi-r3:   167,139,250;      /* rgb of --kofi-acc3 */
}

/* ============================================================
   Ko-Fi — floating button · modal · tiers · sparkles
   Loaded on every page via BaseLayout + hub pages directly
   ============================================================ */

/* ── Floating coffee button (bottom-right, all pages) ── */
.kofi-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 998;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kofi-acc2) 0%, var(--kofi-acc) 100%);
  border: none;
  cursor: pointer;
  font-size: 1.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 4px 20px rgba(var(--kofi-r1),.52), 0 2px 8px rgba(0,0,0,.3);
  animation: kofiFloatBounce 3.2s ease-in-out infinite;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s;
  outline: none;
}
.kofi-float:hover {
  transform: scale(1.14) translateY(-2px);
  box-shadow: 0 8px 28px rgba(var(--kofi-r1),.65);
  animation: none;
}
.kofi-float:focus-visible {
  box-shadow: 0 0 0 3px rgba(var(--kofi-r2),.6), 0 4px 20px rgba(var(--kofi-r1),.5);
}
/* Pulse ring */
.kofi-float::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 2px solid rgba(var(--kofi-r1),.55);
  animation: kofiPulseRing 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes kofiPulseRing {
  0%   { transform: scale(1);   opacity: .65; }
  100% { transform: scale(1.75); opacity: 0;  }
}
@keyframes kofiFloatBounce {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-5px); }
}

/* ── Modal backdrop + card ── */
.kofi-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.kofi-modal.open { opacity: 1; pointer-events: all; }

.kofi-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.kofi-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  margin: 20px;
  background: #09090f;
  border-radius: 28px;
  padding: 36px 32px 28px;
  text-align: center;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: #ededed;
  box-shadow: 0 32px 80px rgba(0,0,0,.75), inset 0 1px 0 rgba(255,255,255,.07);
  transform: translateY(24px) scale(.96);
  transition: transform .32s cubic-bezier(.34,1.56,.64,1);
  overflow: hidden;
}
/* Gradient border via pseudo-element */
.kofi-modal-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 28px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(var(--kofi-r2),.55), rgba(var(--kofi-r1),.2) 50%, rgba(var(--kofi-r3),.4));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.kofi-modal.open .kofi-modal-card { transform: translateY(0) scale(1); }

/* Light mode */
@media (prefers-color-scheme: light) {
  .kofi-modal-card {
    background: #fff;
    color: #06060e;
    box-shadow: 0 32px 80px rgba(0,0,0,.12), 0 0 0 1px rgba(var(--kofi-r1),.12);
  }
}
[data-theme="light"] .kofi-modal-card {
  background: #fff;
  color: #06060e;
  box-shadow: 0 32px 80px rgba(0,0,0,.12), 0 0 0 1px rgba(var(--kofi-r1),.12);
}
[data-theme="light"] .kofi-modal-card::before {
  background: linear-gradient(135deg, rgba(var(--kofi-r1),.3), rgba(var(--kofi-r2),.12) 50%, rgba(var(--kofi-r3),.25));
}

.kofi-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7d8590;
  transition: background .18s, color .18s, transform .2s;
}
.kofi-modal-close:hover { background: rgba(var(--kofi-r1),.18); color: #a5b4fc; transform: rotate(90deg); }
[data-theme="light"] .kofi-modal-close { background: rgba(0,0,0,.06); color: #636c76; }
[data-theme="light"] .kofi-modal-close:hover { background: rgba(var(--kofi-r1),.1); color: #4f46e5; }

/* ── Animated cup ── */
.kofi-cup-wrap {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
}
.kofi-steam { display: flex; gap: 5px; align-items: flex-end; height: 26px; margin-bottom: 2px; }
.kofi-steam span {
  width: 4px;
  border-radius: 99px;
  background: linear-gradient(to top, rgba(var(--kofi-r2),.8), transparent);
  animation: kofiSteam 1.7s ease-in-out infinite;
}
.kofi-steam span:nth-child(1) { height: 14px; }
.kofi-steam span:nth-child(2) { height: 20px; animation-delay: .28s; }
.kofi-steam span:nth-child(3) { height: 12px; animation-delay: .56s; }
@keyframes kofiSteam {
  0%   { opacity: 0;   transform: translateY(0) scaleX(1); }
  45%  { opacity: .8;  transform: translateY(-7px) scaleX(1.2); }
  100% { opacity: 0;   transform: translateY(-18px) scaleX(.8); }
}
.kofi-big-cup {
  font-size: 3.5rem;
  line-height: 1;
  display: block;
  animation: kofiCupBounce 2.2s ease-in-out infinite;
  filter: drop-shadow(0 4px 14px rgba(var(--kofi-r1),.45));
}
@keyframes kofiCupBounce {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50%     { transform: translateY(-6px) rotate(4deg); }
}

/* ── Modal header ── */
.kofi-modal-header h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -.02em;
  text-align: center;
  background: linear-gradient(135deg, #a5b4fc, var(--kofi-acc2), var(--kofi-acc));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kofi-modal-header p {
  font-size: .87rem;
  color: #7d8590;
  max-width: 320px;
  margin: 0 auto 22px;
  line-height: 1.6;
}
[data-theme="light"] .kofi-modal-header p { color: #4a4888; }

/* ── Tier grid ── */
.kofi-tier-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.kofi-tier-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 8px 14px;
  border-radius: 18px;
  background: rgba(var(--kofi-r1),.04);
  border: 1.5px solid rgba(var(--kofi-r1),.14);
  cursor: pointer;
  transition: all .22s cubic-bezier(.34,1.56,.64,1);
  font-family: inherit;
  color: inherit;
}
.kofi-tier-card:hover {
  background: rgba(var(--kofi-r1),.1);
  border-color: rgba(var(--kofi-r2),.4);
  transform: translateY(-4px);
  box-shadow: 0 4px 18px rgba(var(--kofi-r1),.18);
}
.kofi-tier-card.selected {
  background: rgba(var(--kofi-r1),.14);
  border-color: var(--kofi-acc2);
  box-shadow: 0 0 0 3px rgba(var(--kofi-r1),.2), 0 6px 22px rgba(var(--kofi-r1),.28);
  transform: translateY(-4px) scale(1.03);
}
[data-theme="light"] .kofi-tier-card { background: rgba(var(--kofi-r1),.04); border-color: rgba(var(--kofi-r1),.13); }
[data-theme="light"] .kofi-tier-card:hover { background: rgba(var(--kofi-r1),.08); border-color: rgba(var(--kofi-r1),.35); }
[data-theme="light"] .kofi-tier-card.selected { background: rgba(var(--kofi-r1),.1); border-color: var(--kofi-acc); }
.tier-cups { font-size: 1.25rem; letter-spacing: -2px; margin-bottom: 2px; }
.tier-name { font-size: .7rem; font-weight: 700; line-height: 1.2; }
.tier-count { font-size: .63rem; color: #7d8590; }
[data-theme="light"] .tier-count { color: #636c76; }
.tier-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--kofi-acc2), var(--kofi-acc));
  color: #fff;
  font-size: .54rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
  letter-spacing: .04em;
}
.kofi-tier-popular { border-color: rgba(var(--kofi-r2),.28); background: rgba(var(--kofi-r1),.06); }

/* ── Go button ── */
.kofi-go-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 30px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--kofi-acc2) 0%, var(--kofi-acc) 100%);
  color: #fff;
  font-size: .92rem;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 22px rgba(var(--kofi-r1),.45);
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s;
  margin-bottom: 12px;
}
.kofi-go-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 30px rgba(var(--kofi-r1),.58);
}
.kofi-modal-note { font-size: .72rem; color: #505060; margin: 0; }
[data-theme="light"] .kofi-modal-note { color: #aeacc8; }

/* ── Thank-you view ── */
.kofi-thanks-inner { display: flex; flex-direction: column; align-items: center; padding: 8px 0 4px; }
.kofi-thanks-icon {
  font-size: 3.8rem;
  margin-bottom: 14px;
  animation: kofiThanksIn .5s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes kofiThanksIn {
  from { transform: scale(.4) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);    opacity: 1; }
}
.kofi-thanks-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: -.02em;
  text-align: center;
  background: linear-gradient(135deg, #a5b4fc, var(--kofi-acc2), var(--kofi-acc));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kofi-thanks-msg {
  font-size: .87rem;
  color: #7d8590;
  max-width: 320px;
  line-height: 1.65;
  margin: 0 auto 18px;
}
[data-theme="light"] .kofi-thanks-msg { color: #4a4888; }
.kofi-thanks-redirect { font-size: .76rem; color: #505060; margin: 0; }
[data-theme="light"] .kofi-thanks-redirect { color: #aeacc8; }
.kofi-dots::after {
  content: '';
  animation: kofiDots 1.4s steps(4, end) infinite;
}
@keyframes kofiDots {
  0%       { content: ''; }
  25%      { content: '.'; }
  50%      { content: '..'; }
  75%,100% { content: '...'; }
}

/* ── Brew mini-game ── */
#kofiBrewView { text-align: center; padding: 4px 0 2px; }

/* scene container — steam above, mug below */
.brew-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
}

/* steam lines */
.brew-steam-lines {
  display: flex;
  gap: 7px;
  align-items: flex-end;
  height: 28px;
  margin-bottom: 0;
  opacity: 0;
  transition: opacity .5s ease;
}
.brew-steam-lines.brew-steam-active { opacity: 1; }
.brew-steam-lines span {
  width: 4px;
  border-radius: 99px;
  background: linear-gradient(to top, rgba(200,170,120,.9), transparent);
}
.brew-steam-lines.brew-steam-active span { animation: kofiSteam 1.7s ease-in-out infinite; }
.brew-steam-lines span:nth-child(1) { height: 14px; }
.brew-steam-lines span:nth-child(2) { height: 22px; animation-delay: .28s; }
.brew-steam-lines span:nth-child(3) { height: 12px; animation-delay: .56s; }

/* mug float wrapper — positioned so handle can overflow */
.brew-mug-wrap {
  position: relative;
  width: 88px;
  animation: brewMugFloat 2.8s ease-in-out infinite;
}
@keyframes brewMugFloat {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}
.brew-mug-wrap.brew-mug-shake {
  animation: brewMugShake .13s ease-in-out 10 alternate;
}
@keyframes brewMugShake {
  from { transform: rotate(-5deg) translateY(-2px); }
  to   { transform: rotate(5deg)  translateY(-2px); }
}
.brew-mug-wrap.brew-mug-done {
  animation: brewMugPop .48s cubic-bezier(.34,1.56,.64,1) forwards,
             brewMugFloat 2.8s ease-in-out infinite .48s;
}
@keyframes brewMugPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.17) translateY(-9px); }
  100% { transform: scale(1) translateY(0); }
}

/* mug body — dark clay default, tan ceramic in light mode */
.brew-mug-body {
  position: relative;
  width: 88px;
  height: 86px;
  border-radius: 6px 6px 16px 16px;
  background: #2a2535;
  border: 2.5px solid rgba(255,255,255,.14);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.07);
}
[data-theme="light"] .brew-mug-body {
  background: #e8ddd0;
  border-color: #a8916e;
  box-shadow: 0 8px 24px rgba(0,0,0,.22), 0 0 0 1px rgba(0,0,0,.06), inset 0 2px 4px rgba(255,255,255,.7), inset 0 -2px 4px rgba(0,0,0,.08);
}

/* coffee fill — rises from bottom with realistic layered gradient */
.brew-coffee-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  border-radius: 0 0 13px 13px;
  /* dark espresso at bottom → medium roast → golden crema at surface */
  background: linear-gradient(
    to top,
    #170802 0%,
    #2a0e05 15%,
    #4b1d0a 38%,
    #6e3214 62%,
    #9c5728 78%,
    #c88040 88%,
    #dfa055 93%,
    #f2c96a 97%,
    #fad97a 100%
  );
}

/* mug rim highlight */
.brew-mug-body::after {
  content: '';
  position: absolute;
  top: 0;
  left: 8px;
  right: 8px;
  height: 4px;
  border-radius: 0 0 4px 4px;
  background: rgba(255,255,255,.1);
  pointer-events: none;
}
[data-theme="light"] .brew-mug-body::after { background: rgba(255,255,255,.5); }

/* handle */
.brew-mug-handle {
  position: absolute;
  right: -17px;
  top: 18px;
  width: 20px;
  height: 38px;
  border: 3px solid rgba(255,255,255,.18);
  border-left: none;
  border-radius: 0 14px 14px 0;
  background: transparent;
}
[data-theme="light"] .brew-mug-handle { border-color: #a8916e; }

/* saucer */
.brew-mug-saucer {
  position: absolute;
  bottom: -7px;
  left: -8px;
  right: -8px;
  height: 7px;
  border-radius: 0 0 20px 20px;
  background: #1e1b28;
  border: 2px solid rgba(255,255,255,.12);
  border-top: none;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
[data-theme="light"] .brew-mug-saucer { background: #d9ccbc; border-color: #a8916e; }

/* header text */
.brew-header { margin-bottom: 16px; margin-top: 12px; }
.brew-eyebrow {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--kofi-acc2);
  margin-bottom: 5px;
}
.brew-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.02em;
  text-align: center;
  background: linear-gradient(135deg, #a5b4fc, var(--kofi-acc2), var(--kofi-acc));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}
.brew-sub {
  font-size: .82rem;
  color: #7d8590;
  max-width: 290px;
  margin: 0 auto;
  line-height: 1.55;
}
[data-theme="light"] .brew-sub { color: #4a4888; }

/* progress bar */
.brew-bar-wrap { margin-bottom: 20px; }
.brew-bar-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(var(--kofi-r1),.12);
  overflow: hidden;
  margin-bottom: 8px;
}
.brew-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--kofi-acc) 0%, var(--kofi-acc2) 55%, var(--kofi-acc3) 100%);
  box-shadow: 0 0 8px rgba(var(--kofi-r1),.55);
}
.brew-bar-msg {
  font-size: .74rem;
  color: #7d8590;
  text-align: center;
  min-height: 1.1em;
}
[data-theme="light"] .brew-bar-msg { color: #4a4888; }

/* start / claim button */
.brew-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 32px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--kofi-acc2) 0%, var(--kofi-acc) 100%);
  color: #fff;
  font-size: .92rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 22px rgba(var(--kofi-r1),.42);
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s;
  animation: brewBtnGlow 2.4s ease-in-out infinite;
}
.brew-start-btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 30px rgba(var(--kofi-r1),.6);
  animation: none;
}
.brew-start-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  animation: none;
  transform: none;
}
.brew-start-btn.brew-btn-ready {
  background: linear-gradient(135deg, var(--kofi-acc3) 0%, var(--kofi-acc2) 50%, var(--kofi-acc) 100%);
  animation: brewBtnReady 1.3s ease-in-out infinite;
}
@keyframes brewBtnGlow {
  0%,100% { box-shadow: 0 4px 22px rgba(var(--kofi-r1),.42); }
  50%     { box-shadow: 0 6px 30px rgba(var(--kofi-r1),.68); }
}
@keyframes brewBtnReady {
  0%,100% { box-shadow: 0 4px 24px rgba(var(--kofi-r3),.55); transform: scale(1); }
  50%     { box-shadow: 0 8px 36px rgba(var(--kofi-r3),.82); transform: scale(1.04); }
}

/* ── Auto-injected footer strip (pages with footer:true config) ── */
.kofi-footer-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 16px;
  padding: 14px 20px 14px 18px;
  margin: 0 0 28px;
  border-radius: 14px;
  background: rgba(var(--kofi-r1),.06);
  border: 1px solid rgba(var(--kofi-r1),.16);
  transition: border-color .2s, background .2s;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.kofi-footer-strip:hover {
  border-color: rgba(var(--kofi-r2),.32);
  background: rgba(var(--kofi-r1),.09);
}
.kofi-strip-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.kofi-strip-icon { font-size: 1.3rem; flex-shrink: 0; line-height: 1; }
.kofi-strip-text {
  font-size: .82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
  opacity: .75;
}
.kofi-strip-text strong { opacity: 1; font-weight: 600; }
.kofi-strip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--kofi-acc2) 0%, var(--kofi-acc) 100%);
  color: #fff;
  font-size: .76rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 12px rgba(var(--kofi-r1),.35);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.kofi-strip-btn:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 5px 18px rgba(var(--kofi-r1),.5);
}
@media (max-width: 600px) {
  .kofi-footer-strip {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
  }
  .kofi-strip-left {
    justify-content: center;
    gap: 8px;
  }
  .kofi-strip-text {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    font-size: .8rem;
    text-align: center;
  }
  .kofi-strip-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
    font-size: .84rem;
  }
}

/* ── Sparkle particles ── */
.kofi-spark {
  position: fixed;
  pointer-events: none;
  font-size: 1.1rem;
  z-index: 10000;
  line-height: 1;
  animation: kofiSparkFly 1s ease-out forwards;
}
@keyframes kofiSparkFly {
  0%   { opacity: 1; transform: translate(0,0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(var(--sx,0px),var(--sy,-40px)) rotate(var(--rot,0deg)) scale(.3); }
}
