/* Study streak pill (sidebar brand row) and its panel; Nanani and Reader tokens only. */
.sidebar .brand { position: relative; }
.streak-pill {
  --streak-ease: cubic-bezier(.23, 1, .32, 1);
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 10px 4px 7px;
  border: 1px solid var(--sidebar-chip-border);
  border-radius: 999px;
  background: var(--sidebar-chip-bg);
  color: var(--sidebar-ink);
  font: 600 13px/1 var(--font-brand);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: transform 160ms var(--streak-ease), border-color 200ms ease, background-color 200ms ease;
}
.streak-pill[hidden] { display: none; }
@media (hover: hover) and (pointer: fine) {
  .streak-pill:hover { border-color: var(--sidebar-item-border); background: var(--sidebar-item-hover); }
}
.streak-pill:active { transform: scale(.97); }
.streak-pill:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.streak-pill[aria-expanded="true"] { border-color: var(--accent-2); }

.streak-flame { width: 18px; height: 18px; flex: 0 0 auto; overflow: visible; }
.streak-flame-line { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; opacity: .55; }
.streak-flame-fill { fill: var(--accent); transition: clip-path 600ms var(--streak-ease, ease-out); }
.streak-flame-core { fill: none; }
.streak-pill .streak-flame { color: var(--sidebar-muted); }
/* Studied today: the flame is lit, line and core included. */
[data-state="done"] > .streak-flame .streak-flame-fill,
[data-state="done"] .streak-flame .streak-flame-fill { fill: var(--accent); }
[data-state="done"] .streak-flame .streak-flame-line { stroke: var(--accent); opacity: 1; }
[data-state="done"] .streak-flame .streak-flame-core { fill: var(--accent-2); }
/* A broken or absent streak stays quiet: no orange until today's study begins. */
.streak-pill[data-state="lost"] .streak-count,
.streak-pill[data-state="idle"] .streak-count,
.streak-pill[data-state="new"] .streak-count { color: var(--sidebar-muted); }

.streak-pill-note {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  font-weight: 600;
  color: var(--sidebar-ink);
}

/* Reaching today's threshold: one short glow on the flame. */
.streak-pill.streak-ignite .streak-flame { animation: streak-ignite 700ms var(--streak-ease); }
@keyframes streak-ignite {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }
  35% { transform: scale(1.22) translateY(-1px); filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--accent) 70%, transparent)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 transparent); }
}
/* A milestone: the same glow, and the pill opens to say the number. */
.streak-pill.streak-milestone {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent) 22%, var(--sidebar-chip-bg));
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 35%, transparent);
}
.streak-pill.streak-milestone .streak-flame { animation: streak-ignite 700ms var(--streak-ease); }
.streak-pill.streak-milestone .streak-count { display: none; }
.streak-pill.streak-milestone .streak-pill-note { animation: streak-note 3600ms var(--streak-ease) forwards; }
@keyframes streak-note {
  0% { max-width: 0; opacity: 0; }
  12%, 85% { max-width: 9em; opacity: 1; }
  100% { max-width: 9em; opacity: 0; }
}

.streak-panel {
  --streak-ease: cubic-bezier(.23, 1, .32, 1);
  position: absolute;
  z-index: 40;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  box-sizing: border-box;
  width: auto;
  max-width: 340px;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 44px rgba(10, 6, 24, .28), 0 2px 6px rgba(10, 6, 24, .12);
  font-family: var(--sans);
  transform-origin: top right;
  animation: streak-panel-in 180ms var(--streak-ease);
}
.streak-panel[hidden] { display: none; }
@keyframes streak-panel-in { from { opacity: 0; transform: translateY(-4px) scale(.97); } }

.streak-panel-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; }
.streak-panel-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--muted);
}
.streak-panel-mark .streak-flame { width: 26px; height: 26px; }
.streak-panel-title {
  margin: 1px 0 4px;
  font: 700 21px/1.15 var(--font-brand);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-wrap: balance;
}
.streak-panel-line { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); text-wrap: pretty; }
.streak-close {
  width: 28px; height: 28px;
  margin: -4px -6px 0 0;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 400 20px/1 var(--font-brand);
  cursor: pointer;
}
.streak-close:hover { background: var(--hover-bg); color: var(--ink); }
.streak-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.streak-today { margin-top: 16px; }
.streak-today-row { display: flex; justify-content: space-between; font: 600 12px/1.3 var(--font-brand); color: var(--muted); font-variant-numeric: tabular-nums; }
.streak-today-row > span:first-child { color: var(--ink); }
.streak-bar { margin-top: 7px; height: 6px; border-radius: 999px; background: var(--hover-bg); overflow: hidden; }
.streak-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transform-origin: left center;
  transition: transform 400ms var(--streak-ease);
}

.streak-week { margin-top: 16px; }
.streak-week ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.streak-day { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.streak-day-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  box-sizing: border-box;
  border: 1.5px solid var(--line-strong);
  background: transparent;
}
.streak-day[data-status="done"] .streak-day-dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--accent-2) 55%, var(--accent)); }
.streak-day[data-status="pending"] .streak-day-dot { border-style: dashed; border-color: var(--accent); }
.streak-day[data-status="frozen"] .streak-day-dot { border-color: var(--gender-m); background: color-mix(in srgb, var(--gender-m) 22%, transparent); }
.streak-day-name { font: 600 11px/1 var(--font-brand); color: var(--muted); text-transform: uppercase; }
.streak-day[data-status="pending"] .streak-day-name { color: var(--ink); }

.streak-facts { display: flex; gap: 18px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.streak-facts div { display: flex; flex-direction: column; gap: 3px; }
.streak-facts dt { font: 500 11px/1.2 var(--font-brand); color: var(--muted); }
.streak-facts dd { margin: 0; font: 700 15px/1.2 var(--font-brand); color: var(--ink); font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .streak-pill { min-height: 34px; padding: 5px 12px 5px 9px; font-size: 14px; }
  .streak-panel { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .streak-pill, .streak-flame-fill, .streak-bar > span { transition: none; }
  .streak-panel { animation: none; }
  .streak-pill.streak-ignite .streak-flame,
  .streak-pill.streak-milestone .streak-flame { animation: none; }
  .streak-pill.streak-milestone .streak-pill-note { animation: none; max-width: 9em; opacity: 1; }
}
