/* Daily puzzle streak: the dashboard pill (#xt-streak) and the puzzles-page burst. js/core/streak.js */
@property --streak-fill { syntax: '<number>'; inherits: false; initial-value: 0; }

.xt-streak {
  --streak-orange: #FF7A00;
  --streak-gold: #FFC531;
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.3rem 0.35rem 0.3rem 0.3rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff; text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
button.xt-streak { font: inherit; text-align: left; cursor: pointer; }
.xt-streak[hidden] { display: none; }
.xt-streak[aria-expanded="true"] { border-color: rgba(255, 122, 0, 0.55); background: rgba(255, 122, 0, 0.08); }
.xt-streak:hover { color: #fff; transform: translateY(-1px); border-color: rgba(255, 122, 0, 0.45); background: rgba(255, 122, 0, 0.06); }
.xt-streak:focus-visible { outline: 2px solid var(--streak-orange); outline-offset: 3px; }

.xt-streak__flame {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.05rem;
  background: rgba(255, 255, 255, 0.06); color: #6f6f82;
}
.xt-streak__flame i { display: block; transform-origin: 50% 85%; }
.xt-streak[data-state="risk"] .xt-streak__flame { background: rgba(255, 122, 0, 0.12); color: var(--streak-orange); }
.xt-streak[data-state="risk"] .xt-streak__flame i { animation: xt-ember 2.4s ease-in-out infinite; }
.xt-streak[data-state="done"] .xt-streak__flame {
  background: radial-gradient(circle at 50% 70%, var(--streak-gold), var(--streak-orange) 70%);
  color: #fff; box-shadow: 0 0 16px rgba(255, 122, 0, 0.45);
}
.xt-streak[data-state="done"] .xt-streak__flame i { animation: xt-flicker 1.6s ease-in-out infinite; }

.xt-streak__body { display: grid; grid-template-columns: auto auto; column-gap: 0.55rem; align-items: center; line-height: 1.15; }
.xt-streak__count { font-size: 0.92rem; font-weight: 800; white-space: nowrap; }
.xt-streak__week { display: inline-flex; gap: 3px; }
.xt-streak__dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); }
.xt-streak__dot.is-done { background: var(--streak-orange); }
.xt-streak__dot.is-today { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.55); }
.xt-streak__dot.is-today.is-done { background: var(--streak-gold); }
.xt-streak__sub { grid-column: 1 / -1; margin-top: 2px; font-size: 0.72rem; color: #a0a0b0; white-space: nowrap; }
.xt-streak[data-state="risk"] .xt-streak__sub { color: #ffb366; }

.xt-streak__ring {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: baseline; justify-content: center; padding-top: 10px;
  font-size: 0.8rem; line-height: 1; color: #fff;
  background:
    radial-gradient(closest-side, #1a1a26 76%, transparent 78% 100%),
    conic-gradient(var(--streak-orange) calc(var(--streak-fill) * 360deg), rgba(255, 255, 255, 0.1) 0);
  animation: xt-ring-fill 0.9s 0.15s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.xt-streak__ring b { font-weight: 800; }
.xt-streak__ring small { font-size: 0.62rem; color: #a0a0b0; }
.xt-streak[data-state="done"] .xt-streak__ring {
  align-items: center; padding-top: 0;
  background: #2e9e4f; color: #fff; font-size: 0.9rem;
  animation: xt-pop 0.45s 0.1s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes xt-ring-fill { from { --streak-fill: 0; } to { --streak-fill: var(--streak-pct, 0); } }
@keyframes xt-flicker {
  0%, 100% { transform: scale(1) rotate(-4deg); }
  30% { transform: scale(1.1, 1.16) rotate(3deg); }
  60% { transform: scale(0.96, 1.04) rotate(-2deg); }
}
@keyframes xt-ember { 0%, 100% { opacity: 0.65; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1.04); } }
@keyframes xt-pop { from { transform: scale(0.4); } to { transform: scale(1); } }

@media (max-width: 480px) {
  .xt-streak__sub { display: none; }
}

/* Puzzles page: the moment today counts */
.xt-streak-burst {
  position: fixed; top: 84px; left: 50%; z-index: 1200;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 1.2rem 0.7rem 0.8rem; border-radius: 999px;
  background: #1d1d2b; border: 1px solid rgba(255, 122, 0, 0.5);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5), 0 0 28px rgba(255, 122, 0, 0.2);
  color: #fff; font-size: 0.92rem;
  transform: translateX(-50%);
  animation: xt-burst-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.xt-streak-burst.is-leaving { opacity: 0; transform: translate(-50%, -12px); }
.xt-streak-burst strong { color: #FFC531; font-weight: 800; }
.xt-streak-burst span { color: #d5d5e0; }
.xt-streak-burst__flame {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 70%, #FFC531, #FF7A00 70%); color: #fff;
  animation: xt-flicker 1.2s ease-in-out infinite;
}
@keyframes xt-burst-in { from { opacity: 0; transform: translate(-50%, -18px) scale(0.85); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* Card the pill opens: streak + the student's own time on the platform */
/* The header panel is a glass layer (its own stacking context); lift it so the card
   it holds paints above the stat cards that follow it. */
.xt-student-cmd { position: relative; z-index: 30; }
.xt-streak-wrap { position: relative; display: inline-flex; }
.xt-streak-card {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 60;
  width: 330px; max-width: calc(100vw - 32px);
  padding: 1.1rem 1.15rem 1.15rem; border-radius: 18px;
  background: #1a1a27; border: 1px solid rgba(255, 122, 0, 0.3);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.55), 0 0 30px rgba(255, 122, 0, 0.08);
  color: #fff; text-align: left;
  animation: xt-sc-in 0.22s cubic-bezier(0.34, 1.4, 0.64, 1) both; transform-origin: top right;
}
.xt-streak-card[hidden] { display: none; }
@keyframes xt-sc-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: none; } }

.xt-sc__head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.xt-sc__head strong { display: block; font-size: 1.05rem; font-weight: 800; }
.xt-sc__head span { color: #a0a0b0; font-size: 0.8rem; }
.xt-sc__flame { width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: 1.15rem; background: rgba(255, 122, 0, 0.14); color: #FF7A00; }
.xt-sc__flame[data-state="done"] { background: radial-gradient(circle at 50% 70%, #FFC531, #FF7A00 70%); color: #fff; box-shadow: 0 0 16px rgba(255, 122, 0, 0.4); }
.xt-sc__flame i { transform-origin: 50% 85%; animation: xt-flicker 1.8s ease-in-out infinite; }
.xt-sc__close { margin-left: auto; align-self: flex-start; width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.06); color: #a0a0b0; cursor: pointer; }
.xt-sc__close:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }

.xt-sc__today { padding: 0.7rem 0.8rem; border-radius: 12px; background: rgba(255, 255, 255, 0.04); margin-bottom: 1rem; }
.xt-sc__row { display: flex; justify-content: space-between; font-size: 0.85rem; color: #c8c8d6; margin-bottom: 0.45rem; }
.xt-sc__row b { color: #fff; }
.xt-sc__bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.xt-sc__bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #FF7A00, #FFC531); transition: width 0.5s ease; }

.xt-sc__title { margin: 0 0 0.6rem; font-size: 0.85rem; font-weight: 700; color: #c8c8d6; }
.xt-sc__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin-bottom: 0.9rem; }
.xt-sc__stats div { padding: 0.6rem 0.5rem; border-radius: 12px; background: rgba(255, 255, 255, 0.04); text-align: center; }
.xt-sc__stats b { display: block; font-size: 1rem; font-weight: 800; color: #fff; white-space: nowrap; }
.xt-sc__stats span { font-size: 0.72rem; color: #a0a0b0; }

.xt-sc__chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 78px; margin-bottom: 0.6rem; }
.xt-sc__col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.xt-sc__barv { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.xt-sc__barv i { width: 70%; min-height: 3px; border-radius: 5px 5px 2px 2px; background: rgba(255, 122, 0, 0.55); }
.xt-sc__barv i[style*="height:0%"] { background: rgba(255, 255, 255, 0.1); height: 3px !important; }
.xt-sc__col.is-today .xt-sc__barv i { background: linear-gradient(180deg, #FFC531, #FF7A00); }
.xt-sc__col small { font-size: 0.68rem; color: #8e8ea3; }
.xt-sc__col.is-today small { color: #FFC531; font-weight: 700; }

.xt-sc__note { margin: 0 0 0.85rem; font-size: 0.75rem; color: #8e8ea3; }
.xt-sc__cta { width: 100%; justify-content: center; font-size: 0.88rem; padding: 0.65rem 1rem; }

/* On phones the pill sits on the left of the header, so the card opens to the right. */
@media (max-width: 640px) {
  .xt-streak-card { right: auto; left: 0; transform-origin: top left; }
}

@media (prefers-reduced-motion: reduce) {
  .xt-streak, .xt-streak *, .xt-streak-burst, .xt-streak-burst *, .xt-streak-card, .xt-streak-card * { animation: none !important; transition: none !important; }
  .xt-streak__ring { --streak-fill: var(--streak-pct, 0); }
}

