/* =====================================================================
   Amrich UI — Festival stage
   An inline card embedded directly into the page (NOT a modal): the
   murti or the flag sits in the dashboard with its action buttons
   beside it, so nothing is hidden behind an overlay.
   ===================================================================== */

/* ---- Click-burst canvas + CSS shockwave ---- */
.th-fx-click {
  position: fixed;
  inset: 0;
  z-index: 2147481500;
  pointer-events: none;
}
.th-pop {
  position: fixed;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2147481400;
  animation: thPopOut .62s cubic-bezier(.15,.75,.3,1) forwards;
}
@keyframes thPopOut {
  0%   { transform: scale(0); opacity: .85; }
  100% { transform: scale(9); opacity: 0; }
}
.th-pop-diwali      { background: radial-gradient(circle, #fff3c4, transparent 68%); }
.th-pop-holi        { background: radial-gradient(circle, #ffd6ef, transparent 68%); }
.th-pop-independence{ background: radial-gradient(circle, #fff0dc, transparent 68%); }
.th-pop-durga       { background: radial-gradient(circle, #ffe8dc, transparent 68%); }
.th-pop-christmas   { background: radial-gradient(circle, #ffffff, transparent 68%); }
.th-pop-newyear     { background: radial-gradient(circle, #fff6da, transparent 68%); }

/* =====================================================================
   THE GATE — a full-screen welcome shown once at the login door
   ===================================================================== */
body.th-gate-open { overflow: hidden; }

.th-gate {
  position: fixed;
  inset: 0;
  z-index: 2147482900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--th-ink);
  background:
    radial-gradient(120% 90% at 50% -10%, color-mix(in srgb, var(--th-accent) 26%, transparent), transparent 62%),
    linear-gradient(165deg, var(--th-bg1) 0%, var(--th-bg2) 48%, var(--th-bg3) 100%);
  animation: thGateIn .5s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes thGateIn { from { opacity: 0; } to { opacity: 1; } }

/* the gate lifts like a curtain when the ritual is done */
.th-gate.th-gate-leaving { animation: thGateOut .6s cubic-bezier(.6,0,.3,1) forwards; }
@keyframes thGateOut {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-102%); }
}

.th-gate-inner {
  width: min(560px, 100%);
  text-align: center;
  animation: thGateRise .6s cubic-bezier(.22,.61,.36,1) .08s both;
}
@keyframes thGateRise {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.th-gate-head {
  display: flex; align-items: center; justify-content: center;
  gap: 13px; text-align: left; margin-bottom: 14px;
}
.th-gate-mark {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 13px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--th-accent) 16%, var(--th-card));
  border: 1px solid color-mix(in srgb, var(--th-accent) 30%, transparent);
}
.th-gate-mark svg { width: 26px; height: 26px; }
.th-gate-title { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.4px; }
.th-gate-greet { margin: 3px 0 0; font-size: 13px; line-height: 1.5; opacity: .75; }

.th-gate-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 330px;
  padding: 8px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--th-card) 55%, transparent);
  border: 1px solid color-mix(in srgb, var(--th-accent) 18%, transparent);
  overflow: hidden;
}
.th-gate-stage .ap-svg { width: 100%; max-width: 360px; height: auto; max-height: 44vh; display: block; }

.th-gate-foot { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 16px; }
.th-gate-cta {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 14px 28px; border: none; border-radius: 13px; cursor: pointer;
  font: 700 14px/1 'Inter', sans-serif; color: #fff;
  background: linear-gradient(135deg, var(--th-accent), var(--th-accent2));
  box-shadow: 0 16px 32px -14px var(--th-glow);
  transition: transform .2s cubic-bezier(.22,.61,.36,1), filter .2s, box-shadow .2s;
}
.th-gate-cta svg { width: 19px; height: 19px; }
.th-gate-cta:hover:not(:disabled) { transform: translateY(-3px); filter: saturate(1.14); }
.th-gate-cta:active:not(:disabled) { transform: scale(.97); }
.th-gate-cta:disabled { opacity: .55; cursor: default; }

.th-gate-skip {
  padding: 13px 18px; border-radius: 12px; cursor: pointer;
  font: 600 12.5px/1 'Inter', sans-serif; color: var(--th-ink);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--th-ink) 20%, transparent);
  transition: background .2s, border-color .2s;
}
.th-gate-skip:hover { background: color-mix(in srgb, var(--th-ink) 8%, transparent); }

.th-gate-note {
  margin-top: 12px; font-size: 11.8px; line-height: 1.6; opacity: .6;
  max-width: 44ch; margin-left: auto; margin-right: auto;
}

.th-gate-blessing {
  margin-top: 18px;
  font: 800 26px/1.3 'Inter', 'Noto Sans Devanagari', system-ui, sans-serif;
  letter-spacing: 1.5px;
  color: var(--th-accent);
  animation: thBless .9s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes thBless {
  from { opacity: 0; transform: scale(.8); }
  to   { opacity: 1; transform: none; }
}

/* Once the gate has gone, bring the login card in behind it */
body.th-gate-cleared .th-login-card-fx { animation: thCardIn .6s cubic-bezier(.22,.61,.36,1) both; }

.th-gate .th-mantra {
  position: absolute; left: 0; right: 0; bottom: 6px;
  font: 600 13px/1.6 'Inter', 'Noto Sans Devanagari', system-ui, sans-serif;
  text-align: center;
}
.th-gate .th-mantra small { display: block; font-weight: 500; font-size: 11px; opacity: .68; }

.th-gate .th-dhak-wrap { position: absolute; right: 8px; bottom: 8px; width: 84px; }
.th-gate .th-dhak-wrap .ap-dhak { width: 100%; height: auto; }

.th-gate-diwali .ap-rangoli { width: 210px; height: 210px; display: block; margin: 0 auto; }
.th-gate-diwali .th-diya-row { margin-top: -34px; }
.th-gate-ny .th-ny-count { font: 800 84px/1 'Inter', sans-serif; color: var(--th-accent); }
.th-gate-ny .th-ny-count.small { font-size: 32px; letter-spacing: 1px; }
.th-gate-tree .th-tree { width: 180px; height: auto; }
.th-gate-holi .th-balloon-wall { max-width: 340px; }

/* =====================================================================
   FLAG HOISTING
   ===================================================================== */
.th-gate-flag {
  background: linear-gradient(180deg, #cfe9ff 0%, #eef7ff 58%, #dcefdc 100%) !important;
  min-height: 380px;
}
html[data-th-dark="1"] .th-gate-flag {
  background: linear-gradient(180deg, #16213d 0%, #1d2b4a 58%, #16263a 100%) !important;
}
.th-gate-flag .ap-flagpole { max-height: 42vh !important; width: auto; }
.ap-flagpole .ap-flag {
  transform: translateY(348px) scaleY(.07);
  transform-origin: 74px 0;
  transition: transform 3.6s cubic-bezier(.34,.02,.2,1);
}
.ap-flagpole.th-hoisted .ap-flag {
  transform: translateY(34px) scaleY(1);
  animation: thFlagWave 3s ease-in-out 3.4s infinite;
}
@keyframes thFlagWave {
  0%,100% { transform: translateY(34px) scaleY(1) skewY(0deg); }
  30%     { transform: translateY(34px) scaleY(1) skewY(1.7deg); }
  65%     { transform: translateY(34px) scaleY(1) skewY(-1.5deg); }
}
.ap-flagpole .ap-rope-grip { transition: transform 3.6s cubic-bezier(.34,.02,.2,1); cursor: grab; }
.ap-flagpole.th-hoisted .ap-rope-grip { transform: translateY(-316px); }




/* =====================================================================
   PRATIMA — the figure never animates, only the offerings
   ===================================================================== */
.ap-halo { animation: thHaloBreathe 5.5s ease-in-out infinite; transform-origin: center; }
@keyframes thHaloBreathe { 0%,100% { opacity: .8; transform: scale(1); } 50% { opacity: 1; transform: scale(1.05); } }
.ap-flame { transform-origin: bottom center; animation: thFlameFlick .55s ease-in-out infinite alternate; }
@keyframes thFlameFlick {
  from { transform: scaleY(1) scaleX(1); }
  to   { transform: scaleY(1.3) scaleX(.86) translateX(.8px); }
}
.ap-lamp-glow { animation: thLampGlow 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes thLampGlow { 0%,100% { opacity: .75; transform: scale(1); } 50% { opacity: 1; transform: scale(1.13); } }
.ap-chal { animation: thChalShine 9s ease-in-out infinite; }
@keyframes thChalShine { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.07); } }

.th-dhak-wrap {
  position: absolute; right: 10px; bottom: 8px; width: 92px;
}
.th-dhak-wrap .ap-dhak { width: 100%; height: auto; }
.ap-dhak-stick  { transform-origin: 55px 44px; }
.ap-dhak-stick2 { transform-origin: 85px 44px; }
.th-dhak-play .ap-dhak-stick  { animation: thStick .32s ease-in-out infinite; }
.th-dhak-play .ap-dhak-stick2 { animation: thStick .32s ease-in-out .16s infinite; }
.th-dhak-play .ap-dhak        { animation: thDhakShake .32s ease-in-out infinite; }
@keyframes thStick { 0%,100% { transform: rotate(-28deg); } 50% { transform: rotate(8deg); } }
@keyframes thDhakShake { 0%,100% { transform: translateY(0) rotate(-1.2deg); } 50% { transform: translateY(-4px) rotate(1.2deg); } }

.th-hamsa { animation: thHamsa 6s ease-in-out infinite; transform-box: fill-box; }
@keyframes thHamsa { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* =====================================================================
   DIWALI — rangoli + lightable diyas
   ===================================================================== */
.th-diwali-art { padding-bottom: 18px; }
.th-diwali-art .ap-rangoli {
  width: 230px; height: 230px; display: block; margin: 0 auto;
  animation: thRangoli 30s linear infinite;
}
@keyframes thRangoli { to { transform: rotate(360deg); } }
.th-diya-row {
  display: flex; justify-content: center; gap: 2px; flex-wrap: wrap;
  margin-top: -38px; position: relative; z-index: 2;
}
.ap-diya {
  width: 58px; height: 58px; cursor: pointer;
  transition: transform .2s cubic-bezier(.22,.61,.36,1);
}
.ap-diya:hover { transform: translateY(-6px) scale(1.07); }
.ap-diya:focus-visible { outline: 2px solid var(--th-accent); outline-offset: 2px; border-radius: 8px; }
.ap-diya.th-lit .ap-diya-flame {
  opacity: 1;
  animation: thFlameFlick .5s ease-in-out infinite alternate;
  transform-origin: 44px 48px;
}
.ap-diya.th-lit .ap-diya-glow { opacity: 1; animation: thLampGlow 2.2s ease-in-out infinite; }

/* =====================================================================
   HOLI — balloon wall
   ===================================================================== */
.th-balloon-wall {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 400px;
  padding: 12px 0;
}
.th-balloon {
  position: relative;
  aspect-ratio: .8;
  min-height: 54px;
  border-radius: 50% 50% 46% 46%;
  cursor: pointer;
  border: none;
  animation: thBalloonFloat 3.6s ease-in-out infinite;
  transition: transform .16s;
}
.th-balloon::after {
  content: ""; position: absolute; left: 26%; top: 18%;
  width: 22%; height: 26%; border-radius: 50%;
  background: rgba(255,255,255,.55);
}
.th-balloon:hover { transform: scale(1.09); }
.th-balloon.th-burst { animation: thBalloonBurst .32s ease-out forwards; pointer-events: none; }
@keyframes thBalloonBurst {
  0%   { transform: scale(1); opacity: 1; }
  40%  { transform: scale(1.35); opacity: .8; }
  100% { transform: scale(.15); opacity: 0; }
}
@keyframes thBalloonFloat {
  0%,100% { transform: translateY(0) rotate(-1.5deg); }
  50%     { transform: translateY(-7px) rotate(1.5deg); }
}

/* Christmas bulbs */
.th-tree .th-bulb { animation: thBulb 1.9s ease-in-out infinite; }
@keyframes thBulb { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

/* New Year counter */
.th-ny-count { font: 800 76px/1 'Inter', sans-serif; color: var(--th-accent); }
.th-ny-count.small { font-size: 40px; }

/* =====================================================================
   FLOATING RE-OPEN BUTTON (when the stage has been dismissed, or the
   page has no obvious place to put a card)
   ===================================================================== */
#thFestBtn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--th-accent3), var(--th-accent));
  box-shadow: 0 8px 22px -6px var(--th-glow), 0 0 0 3px rgba(255,255,255,.55);
  position: relative;
  transition: transform .25s cubic-bezier(.22,.61,.36,1);
}
#thFestBtn svg { width: 24px; height: 24px; position: relative; z-index: 1; }
#thFestBtn:hover { transform: scale(1.12) rotate(8deg); }
/* A transform/opacity ring instead of an animated box-shadow: the shadow
   version repainted the button every frame, this one is composited. */
#thFestBtn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--th-accent3);
  animation: thFestPulse 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes thFestPulse {
  0%   { transform: scale(1);   opacity: .8; }
  70%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}
html[data-th-lite="1"] #thFestBtn::after { animation: none; opacity: 0; }

/* =====================================================================
   RESPONSIVE + ACCESSIBILITY
   ===================================================================== */
@media (max-width: 640px) {
  .th-gate { padding: 12px; }
  .th-gate-title { font-size: 18px; }
  .th-gate-stage { min-height: 260px; }
  .th-gate-foot { flex-direction: column; }
  .th-gate-cta, .th-gate-skip { width: 100%; justify-content: center; }
  .ap-diya { width: 46px; height: 46px; }
  .th-gate .th-dhak-wrap { width: 62px; }
  .th-gate-ny .th-ny-count { font-size: 56px; }
  .th-gate-blessing { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  .th-gate, .th-gate-inner, .th-balloon, .ap-halo, .ap-flame, .ap-lamp-glow,
  .ap-chal, .th-dhak-wrap, .th-hamsa, .ap-rangoli { animation: none !important; }
  .ap-flagpole .ap-flag, .ap-flagpole .ap-rope-grip { transition-duration: .01ms !important; }
}
html[data-th-motion="off"] .th-fx-click,
html[data-th-motion="off"] .th-pop { display: none !important; }

@media print {
  .th-gate, #thFestBtn, .th-fx-click, .th-pop { display: none !important; }
}

/* ---- graceful degradation ---- */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .th-gate { background: var(--th-bg2); }
  .th-gate-mark { background: rgba(128,128,128,.1); border-color: rgba(128,128,128,.24); }
  .th-gate-stage { background: var(--th-card); border-color: rgba(128,128,128,.2); }
  .th-gate-skip { border-color: rgba(128,128,128,.28); }
}
@supports not (inset: 0) {
  .th-fx-click { top: 0; right: 0; bottom: 0; left: 0; }
}
@supports not (aspect-ratio: .8) {
  .th-balloon { height: 62px; }
}
@supports not (gap: 10px) {
  .th-stage-side > * { margin-bottom: 8px; }
  .th-balloon-wall > * { margin: 0 6px 6px 0; }
}
