/* The Tally tile, drawn by js/tally-tile.js: the scene from Tally's own sign-in page (Fitness: public/fitness/js/signin.js and
   the si- rules in public/fitness/styles.css), laid out for a card that is wider than tall. A glass card on drifting light in the
   app's four colours: a message to Claude or ChatGPT becomes measured food, a weigh-in lands on the trend, and the week's lifts
   and runs sit beside it. It is light, and dark when the site is. The scene is laid out at a fixed size and scaled to the tile. */

.lede-image.tally-tile { overflow: hidden; }
.tally-tile .tt {
	color-scheme: light;
	--page: light-dark(#f6f5f1, #0e0e0d);
	--ink: light-dark(#0b0b0b, #f0efec);
	--ink-2: light-dark(#52514e, #c3c2b7);
	--muted: light-dark(#898781, #8d8b84);
	--line: light-dark(rgba(11, 11, 11, 0.08), rgba(255, 255, 255, 0.08));
	--lift: light-dark(#2a78d6, #3987e5);
	--run: light-dark(#eb6834, #d95926);
	--weight: light-dark(#6250d6, #9085e9);
	--food: light-dark(#1baf7a, #199e70);
	--food-wash: light-dark(rgba(27, 175, 122, 0.14), rgba(25, 158, 112, 0.2));
	--font: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", sans-serif;
	--display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
	--si-glass: light-dark(rgba(255, 255, 255, 0.5), rgba(34, 34, 32, 0.48));
	--si-edge: light-dark(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.11));
	--si-shine: light-dark(rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.09));
	--si-card: light-dark(rgba(255, 255, 255, 0.74), rgba(20, 20, 19, 0.56));
	--si-card-edge: light-dark(rgba(11, 11, 11, 0.06), rgba(255, 255, 255, 0.07));
	--si-solid: light-dark(#fff, #1b1b1a);
	--si-field: light-dark(rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.06));
	--si-track: light-dark(rgba(11, 11, 11, 0.06), rgba(255, 255, 255, 0.07));
	--si-claude: #d97757;
	--si-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--si-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
	position: absolute; inset: 0; overflow: hidden;
	background: var(--page); color: var(--ink);
	font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; text-align: left;
}
html.dark-mode .tally-tile .tt { color-scheme: dark; }
.tally-tile .tt *, .tally-tile .tt *::before, .tally-tile .tt *::after { box-sizing: border-box; }

/* The light: four glows, one per colour, drifting. */
.tt-light { position: absolute; inset: 0; pointer-events: none; }
.tt .si-glow { position: absolute; width: 85%; aspect-ratio: 1; border-radius: 50%; opacity: light-dark(0.6, 0.4); animation: tt-drift 38s ease-in-out infinite alternate; }
.tt .si-g-food { background: radial-gradient(closest-side, light-dark(rgba(27, 175, 122, 0.55), rgba(25, 158, 112, 0.6)), transparent); right: -22%; top: -45%; }
.tt .si-g-weight { background: radial-gradient(closest-side, light-dark(rgba(98, 80, 214, 0.42), rgba(120, 104, 230, 0.6)), transparent); right: 0; bottom: -70%; animation-duration: 46s; animation-direction: alternate-reverse; }
.tt .si-g-lift { background: radial-gradient(closest-side, light-dark(rgba(42, 120, 214, 0.36), rgba(57, 135, 229, 0.46)), transparent); left: -40%; top: -50%; animation-duration: 52s; }
.tt .si-g-run { background: radial-gradient(closest-side, light-dark(rgba(235, 104, 52, 0.3), rgba(217, 89, 38, 0.38)), transparent); left: -25%; bottom: -70%; width: 75%; animation-duration: 42s; animation-direction: alternate-reverse; }
@keyframes tt-drift {
	0% { transform: translate3d(0, 0, 0) scale(1); }
	50% { transform: translate3d(-5%, 4%, 0) scale(1.06); }
	100% { transform: translate3d(4%, -3%, 0) scale(0.97); }
}

/* The stage: laid out at a fixed size, scaled to the tile from its top left corner. */
.tt-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; padding: 22px 24px; }

/* The glass: the chat and today on the left, the week and the weight on the right. */
.tt .si-glass {
	position: relative; overflow: hidden; height: 100%; padding: 16px; border-radius: 30px;
	display: grid; grid-template-columns: minmax(0, 1fr) 222px; column-gap: 14px;
	background: var(--si-glass);
	-webkit-backdrop-filter: blur(28px) saturate(170%); backdrop-filter: blur(28px) saturate(170%);
	border: 1px solid var(--si-edge);
	box-shadow: 0 1px 0 var(--si-shine) inset, 0 30px 60px -30px light-dark(rgba(40, 40, 60, 0.3), rgba(0, 0, 0, 0.6)), 0 12px 24px -12px light-dark(rgba(40, 40, 60, 0.14), rgba(0, 0, 0, 0.4));
}
.tt .si-glass::before {
	content: ""; position: absolute; inset: 0 0 auto 0; height: 45%; pointer-events: none;
	background: linear-gradient(180deg, light-dark(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.04)), transparent);
}
.tt-l { position: relative; display: flex; flex-direction: column; min-width: 0; }
.tt-narrow .si-glass { grid-template-columns: minmax(0, 1fr); }
.tt-narrow .si-pair { display: none; }
.tt-narrow .si-glass { padding: 14px; border-radius: 26px; }
.tt-narrow .si-chat { height: 76px; }
.tt-narrow .si-day { padding: 12px 16px 2px; margin-top: 6px; }
.tt-narrow .si-head { padding-bottom: 10px; }
.tt-narrow .si-row { padding: 6px 0; }

/* Chat: which assistant, the composer / sent bubble, and the reply. */
.tt .si-chat { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; height: 80px; flex: none; }
.tt .si-ais {
	--i: 0; position: relative; isolation: isolate; align-self: start;
	display: flex; gap: 2px; padding: 3px; border-radius: 999px; height: 44px; align-items: center;
	background: var(--si-track);
}
.tt .si-ais::before {
	content: ""; position: absolute; left: 3px; top: 3px; width: 38px; height: 38px; border-radius: 50%; z-index: -1;
	background: var(--si-solid); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 4px 10px -4px rgba(0, 0, 0, 0.18);
	transform: translateX(calc(var(--i) * 40px)); transition: transform 0.55s var(--si-spring);
}
.tt .si-ai { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); opacity: 0.55; transition: color 0.4s, opacity 0.4s, transform 0.5s var(--si-spring); }
.tt .si-ai svg { width: 18px; height: 18px; }
.tt .si-ai.on { opacity: 1; transform: scale(1.06); }
.tt .si-ai.si-claude.on, .tt .si-av.si-claude { color: var(--si-claude); }
.tt .si-ai.si-chatgpt.on, .tt .si-av.si-chatgpt { color: var(--ink); }
.tt .si-box { position: relative; height: 44px; }
.tt .si-msg {
	position: absolute; right: 0; top: 0; height: 44px; max-width: 100%;
	display: flex; align-items: center; padding: 0 16px; border-radius: 22px 22px 6px 22px;
	background: var(--ink); color: var(--page); white-space: nowrap; overflow: hidden;
	font: 500 15.5px/1 var(--font); letter-spacing: -0.005em;
	box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.35);
	transition: width 0.55s var(--si-ease), background-color 0.45s, color 0.45s, border-radius 0.5s var(--si-ease), box-shadow 0.45s, opacity 0.35s var(--si-ease), transform 0.5s var(--si-ease);
}
.tt .si-msg.compose {
	background: var(--si-field); color: var(--ink); border-radius: 22px; padding-right: 48px;
	box-shadow: 0 0 0 1px var(--si-card-edge) inset, 0 2px 8px -4px rgba(0, 0, 0, 0.1);
}
.tt .si-msg.gone { opacity: 0; transform: translateY(-10px) scale(0.96); }
.tt .si-msg.pre { opacity: 0; transform: translateY(6px); }
.tt .si-w { display: inline-block; white-space: pre; transition: opacity 0.45s var(--si-ease), transform 0.6s var(--si-ease), filter 0.45s; }
.tt .si-w.si-evap { opacity: 0; transform: translateY(6px); filter: blur(4px); }
.tt .si-ph { position: absolute; left: 16px; color: var(--muted); opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.tt .si-msg.compose.empty .si-ph { opacity: 1; }
.tt .si-caret { display: inline-block; width: 2px; height: 1.15em; margin-left: 1px; background: var(--lift); border-radius: 1px; animation: tt-blink 1s steps(1) infinite; }
.tt .si-caret[hidden] { display: none; }
.tt .si-msg.compose.empty .si-caret { position: absolute; left: 15px; }
@keyframes tt-blink { 50% { opacity: 0; } }
.tt .si-send {
	position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; border-radius: 50%;
	display: grid; place-items: center; background: var(--si-track); color: var(--muted);
	opacity: 0; transform: scale(0.6); transition: opacity 0.3s, transform 0.4s var(--si-spring), background-color 0.25s, color 0.25s;
}
.tt .si-send svg { width: 15px; height: 15px; }
.tt .si-msg.compose .si-send { opacity: 1; transform: none; }
.tt .si-msg.compose:not(.empty) .si-send { background: var(--ink); color: var(--page); }
.tt .si-msg.tap .si-send { transform: scale(0.82); }

.tt .si-reply {
	grid-column: 1 / -1; align-self: end; height: 30px;
	display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2);
	transition: opacity 0.45s var(--si-ease), transform 0.6s var(--si-ease);
}
.tt .si-reply.pre { opacity: 0; transform: translateY(6px); }
.tt .si-reply.gone { opacity: 0; transform: translateY(-6px); }
.tt .si-who { display: inline-flex; align-items: center; gap: 7px; }
.tt .si-who b { color: var(--ink); font-weight: 650; }
.tt .si-av { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--si-solid); box-shadow: 0 0 0 1px var(--si-card-edge); }
.tt .si-av svg { width: 13px; height: 13px; }
.tt .si-check { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--food); color: #fff; flex: none; animation: tt-pop 0.5s var(--si-spring); }
.tt .si-check svg { width: 11px; height: 11px; }
.tt .si-done { display: inline-flex; align-items: center; gap: 6px; }
.tt .si-done::before { content: "·"; color: var(--muted); margin-right: 1px; }
.tt .si-done[hidden], .tt .si-dots[hidden] { display: none; }
.tt .si-dots { display: inline-flex; gap: 4px; }
.tt .si-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: tt-think 1s ease-in-out infinite; }
.tt .si-dots i:nth-child(2) { animation-delay: 0.15s; }
.tt .si-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tt-think { 0%, 100% { opacity: 0.3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
@keyframes tt-pop { from { transform: scale(0); } }

/* Cards inside the glass. */
.tt .si-card {
	position: relative; border-radius: 22px; background: var(--si-card); border: 1px solid var(--si-card-edge);
	box-shadow: 0 1px 2px light-dark(rgba(11, 11, 11, 0.04), transparent), 0 10px 30px -14px light-dark(rgba(11, 11, 11, 0.16), rgba(0, 0, 0, 0.5));
}
.tt .si-eyebrow { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: 0.01em; line-height: 1.3; }
.tt .si-pip { width: 8px; height: 8px; border-radius: 3px; background: var(--k); }
.tt .si-day { flex: 1; padding: 16px 18px 4px; margin-top: 8px; }
.tt .si-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.tt .si-kcal { font: 700 30px/1.1 var(--display); letter-spacing: -0.025em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tt .si-kcal small, .tt .si-wt-n small { font: 600 14px/1 var(--font); color: var(--muted); letter-spacing: 0; margin-left: 3px; }
.tt .si-macros { font-size: 13px; color: var(--ink-2); margin-top: 3px; font-variant-numeric: tabular-nums; }
.tt .si-macros b { font-weight: 650; color: var(--ink); }
.tt .si-ring { width: 62px; height: 62px; position: relative; flex: none; }
.tt .si-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.tt .si-track { stroke: var(--food-wash); }
.tt .si-fill { stroke: var(--food); transition: stroke-dashoffset 1.6s var(--si-ease), opacity 0.3s; }
.tt .si-ring-l { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font: 700 13px/1.05 var(--display); font-variant-numeric: tabular-nums; }
.tt .si-ring-l small { display: block; font: 500 9.5px/1.1 var(--font); color: var(--muted); }

.tt .si-rows { position: relative; }
.tt .si-row {
	display: grid; grid-template-columns: 42px minmax(0, 1fr) auto auto; column-gap: 12px; align-items: center;
	padding: 10px 0; transition: opacity 0.6s var(--si-ease), transform 0.6s var(--si-ease);
}
.tt .si-row + .si-row { border-top: 1px solid var(--line); }
.tt .si-row img { width: 42px; height: 42px; border-radius: 12px; display: block; transition: transform 0.7s var(--si-spring), opacity 0.4s var(--si-ease); }
.tt .si-t { min-width: 0; }
.tt .si-title { font: 600 14.5px/1.3 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt .si-sub { font-size: 12.5px; line-height: 1.3; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt .si-n { text-align: right; font: 650 14.5px/1.2 var(--font); font-variant-numeric: tabular-nums; min-width: 3ch; }
.tt .si-n small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.tt .si-n.si-p { color: var(--ink-2); font-weight: 550; min-width: 4ch; }
.tt .si-row .si-sub, .tt .si-row .si-n { transition: opacity 0.5s var(--si-ease), transform 0.6s var(--si-ease); }
.tt .si-row .si-p { transition-delay: 0.08s; }
.tt .si-row.pre img { opacity: 0; transform: scale(0.5) rotate(-8deg); }
.tt .si-row.pre .si-title { opacity: 0; }
.tt .si-row.pre .si-sub, .tt .si-row.pre .si-n { opacity: 0; transform: translateY(4px); }
.tt .si-row.pre + .si-row { border-top-color: transparent; }
.tt .si-row.out { opacity: 0; transform: translateY(-4px); }
.tt .si-empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13.5px; color: var(--muted); opacity: 0; pointer-events: none; transition: opacity 0.5s var(--si-ease); }
.tt .si-empty.on { opacity: 1; }

/* This week, and the weight under it. */
.tt .si-pair { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tt .si-week { padding: 14px 14px 13px; }
.tt .si-range { margin-left: auto; font-weight: 500; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.tt .si-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 12px 0; }
.tt .si-wd { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; line-height: 1; font-weight: 600; color: var(--muted); }
.tt .si-wd.si-today { color: var(--ink); }
.tt .si-slot { position: relative; width: 100%; aspect-ratio: 1; border-radius: 30%; background: var(--si-track); display: grid; place-items: center; }
.tt .si-today .si-slot { box-shadow: 0 0 0 2px var(--si-solid), 0 0 0 3.5px var(--ink); }
.tt .si-slot i { position: absolute; inset: 0; border-radius: inherit; background: var(--k); display: grid; place-items: center; }
.tt .si-slot i svg { width: 55%; height: 55%; color: #fff; }
.tt .si-slot.si-plan { background: color-mix(in srgb, var(--k) 15%, transparent); }
.tt .si-slot.si-plan::after { content: ""; width: 24%; aspect-ratio: 1; border-radius: 50%; background: var(--k); opacity: 0.8; }
.tt .si-lift { --k: var(--lift); }
.tt .si-run { --k: var(--run); }
.tt .si-tally { display: flex; gap: 12px; font-size: 12px; line-height: 1.3; color: var(--muted); white-space: nowrap; }
.tt .si-tally span { display: inline-flex; align-items: center; gap: 5px; }
.tt .si-tally span::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--k); }
.tt .si-tally b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

.tt .si-wt { flex: 1; padding: 14px 14px 14px; display: flex; flex-direction: column; overflow: hidden; }
.tt .si-wt-n { margin-top: 8px; font: 700 26px/1.05 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; transition: opacity 0.35s; }
.tt .si-wt-sub { font-size: 12.5px; font-weight: 600; color: var(--weight); margin-top: 3px; transition: opacity 0.5s var(--si-ease); }
.tt .si-spark { position: relative; margin-top: auto; padding-top: 8px; }
.tt .si-spark svg { width: 100%; height: 96px; display: block; overflow: visible; }
.tt .si-area { fill: var(--weight); opacity: 0.13; transition: opacity 0.6s; }
.tt .si-ln { fill: none; stroke: var(--weight); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.tt .si-seg { stroke-dasharray: 1; stroke-dashoffset: 0; transition: stroke-dashoffset 0.9s var(--si-ease), opacity 0.2s; }
.tt .si-spark i { position: absolute; left: 98%; top: calc(8px + 96px * 0.875); width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--weight); }
.tt .si-dot { box-shadow: 0 0 0 2.5px var(--si-solid); transition: transform 0.7s var(--si-spring), opacity 0.3s; }
.tt .si-halo { opacity: 0; }
.tt .si-wt.pre .si-seg { stroke-dashoffset: 1; opacity: 0; }
.tt .si-wt.pre .si-seg-area { opacity: 0; }
.tt .si-wt.pre .si-dot { transform: scale(0); opacity: 0; }
.tt .si-wt.land .si-halo { animation: tt-halo 1.2s var(--si-ease); }
@keyframes tt-halo { from { opacity: 0.4; transform: scale(1); } to { opacity: 0; transform: scale(4); } }

/* Words in flight from the message to the card. */
.tt .si-fly { position: absolute; left: 0; top: 0; z-index: 5; white-space: pre; pointer-events: none; transform-origin: 0 0; will-change: transform; }
.tt.instant *, .tt.instant *::before { transition: none !important; }
.tt.tt-paused *, .tt.tt-paused *::before, .tt.tt-paused *::after { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
	.tt .si-glow { animation: none; }
}
