/* ============================================================
   Zenith light and motion (every page, loaded after style.css).

   One idea carries the look: a light that follows his day. A soft
   "sun" sits above the page at the London time of day (left in the
   morning, right at night), cool at dawn, white by day, amber after
   sign-off, a low ember past bedtime. Cards catch it on their top
   edge. Everything else moves only to answer what he does: pages
   morph into each other, numbers roll, ticks land, levels pop.
   prefers-reduced-motion turns all of it off.
   ============================================================ */
@view-transition { navigation: auto; }

:root {
  --out: cubic-bezier(.16, 1, .3, 1);
  --glide: cubic-bezier(.2, .9, .25, 1.06);
  --pop: cubic-bezier(.3, 1.4, .5, 1);
  --sun-x: 50%; --sun-y: -40vh; --sun-a: 1;
  --sun: 205, 214, 255; --sun2: 120, 140, 255;
  --glass: rgba(18, 18, 20, .72);
  --glass-hi: rgba(28, 28, 31, .82);
  --edge: rgba(255, 255, 255, .075);
  --edge-hi: rgba(255, 255, 255, .14);
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --glide: linear(0, 0.059, 0.198, 0.371, 0.547, 0.705, 0.835, 0.934, 1.003, 1.045, 1.066, 1.072, 1.068, 1.058, 1.046, 1.033, 1.022, 1.012, 1.005, 1, 0.997, 0.995, 0.995, 0.995, 0.996, 0.997, 0.998, 0.998, 0.999, 1);
    --pop: linear(0, 0.083, 0.281, 0.528, 0.77, 0.972, 1.115, 1.196, 1.221, 1.204, 1.161, 1.107, 1.053, 1.008, 0.976, 0.957, 0.951, 0.955, 0.964, 0.976, 0.988, 0.998, 1.005, 1.009, 1.011, 1.01, 1.008, 1.005, 1.003, 1.001, 0.999, 1);
  }
}
/* The light's colour by phase of the day (ui.applyPhase sets data-phase). */
html[data-phase="morning"] { --sun: 160, 182, 255; --sun2: 255, 150, 205; }
html[data-phase="day"] { --sun: 205, 214, 255; --sun2: 110, 150, 255; }
html[data-phase="evening"] { --sun: 255, 170, 100; --sun2: 255, 110, 80; }
html[data-phase="night"] { --sun: 255, 128, 70; --sun2: 150, 70, 40; --sun-a: .55; }
html.night { --glass: rgba(22, 18, 15, .74); --glass-hi: rgba(32, 26, 21, .84); --edge: rgba(255, 220, 190, .07); --edge-hi: rgba(255, 220, 190, .13); }

html { background: var(--bg); }
body { background: transparent; }
::selection { background: color-mix(in srgb, var(--accent, #2997ff) 38%, transparent); color: var(--text); }
* { scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- the light ---------- */
.fx-ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; contain: strict; view-transition-name: kz-ambient; }
.fx-ambient i { position: absolute; display: block; }
.fx-ambient .sun {
  left: var(--sun-x); top: var(--sun-y); width: 120vmax; height: 84vh; translate: -50% 0;
  background: radial-gradient(closest-side, rgba(var(--sun), .26), rgba(var(--sun), .095) 44%, rgba(var(--sun), 0) 76%);
  opacity: var(--sun-a); animation: fx-breathe 16s ease-in-out infinite;
  transition: left 3s var(--out), top 3s var(--out), opacity 1.5s;
}
.fx-ambient .bloom {
  right: -18vmax; bottom: -46vh; width: 90vmax; height: 80vh;
  background: radial-gradient(closest-side, rgba(var(--sun2), .06), rgba(var(--sun2), 0) 70%);
  animation: fx-drift 40s ease-in-out infinite alternate;
}
.fx-ambient .grain {
  inset: -50%; opacity: .045; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes fx-breathe { 0%, 100% { transform: scale(1); opacity: var(--sun-a); } 50% { transform: scale(1.06); opacity: calc(var(--sun-a) * .82); } }
@keyframes fx-drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-8vmax, -4vh, 0); } }

/* ---------- surfaces: cards catch the light on their top edge ---------- */
/* :where() keeps these at zero specificity, so a card that is sticky or fixed stays so. */
:where(.card, .fx-spot) { position: relative; isolation: isolate; }
/* Cards are a touch see-through (style.css .card uses --card-glass), so the light tints them. */
:root { --card-glass: color-mix(in srgb, var(--card, #151517) 84%, transparent); }
.card {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, 0) 34%);
  box-shadow: 0 22px 44px -32px rgba(0, 0, 0, .75);
}
.todo-group > summary { background: color-mix(in srgb, var(--card, #151517) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
/* The glint: a hairline of the light's colour just inside the top edge. */
.card::before {
  content: ""; position: absolute; left: 10%; right: 10%; top: 0; height: 1px; pointer-events: none; z-index: 1;
  background: linear-gradient(90deg, rgba(var(--sun), 0), rgba(var(--sun), .55), rgba(var(--sun), 0));
  transition: left .6s var(--out), right .6s var(--out), opacity .4s;
}
.kz-bar.card::before, .title-card::before { display: none; }
/* Things you can click follow the pointer with a soft light (spec 6.1: clickable lifts and brightens). */
.fx-spot::after, a.go::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  background: radial-gradient(520px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, .055), transparent 42%);
  opacity: 0; transition: opacity .45s var(--out);
}
.fx-spot:hover::after, a.go:hover::after { opacity: 1; }
a.go:hover::before, .fx-spot:hover::before { left: 4%; right: 4%; }
a.go { transition: transform .5s var(--glide), border-color .3s, background-color .3s; }
a.go:hover { transform: translateY(-3px); }
a.go:active { transform: translateY(-1px) scale(.992); transition-duration: .12s; }

/* ---------- arrival: one orchestrated entrance per page ---------- */
@keyframes fx-rise { from { transform: translateY(20px) scale(.985); } to { transform: none; } }
@keyframes fx-fade { from { opacity: 0; filter: blur(5px); } to { opacity: 1; filter: none; } }
.card.reveal, .fx-in {
  animation: fx-rise .95s var(--glide) both, fx-fade .6s var(--out) both;
  animation-delay: calc(var(--i, 0) * 55ms + 40ms);
}
html.settled .card.reveal, html.settled .fx-in { animation: none; }
/* Words of a headline arrive one after another (fx.words). */
.fx-w { display: inline-block; white-space: pre; animation: fx-word .7s var(--out) both; animation-delay: calc(var(--w, 0) * 38ms + 120ms); }
.fx-w.still { animation: none; } /* the same words after a refresh */
@keyframes fx-word { from { opacity: 0; transform: translateY(.42em); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }

/* ---------- numbers roll like an odometer (fx.roll) ---------- */
.fx-roll { display: inline-flex; vertical-align: top; line-height: inherit; font-variant-numeric: tabular-nums; }
.fx-roll .d { display: inline-block; height: 1.04em; line-height: 1.04em; overflow: hidden; position: relative; }
.fx-roll .s { display: flex; flex-direction: column; transition: transform 1.2s var(--glide); transition-delay: calc(var(--k, 0) * 70ms); }
.fx-roll .s > span { display: block; height: 1.04em; line-height: 1.04em; text-align: center; }
.fx-roll .c { display: inline-block; line-height: 1.04em; height: 1.04em; }

/* ---------- buttons ---------- */
.btn { transition: background-color .2s, border-color .2s, transform .35s var(--glide), color .2s, box-shadow .3s; }
.btn:active:not(:disabled) { transform: scale(.965); transition-duration: .1s; }
.btn.primary { box-shadow: 0 0 0 0 rgba(var(--sun), 0), 0 8px 24px -10px rgba(255, 255, 255, .35); position: relative; overflow: hidden; }
.btn.primary::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .55) 48%, transparent 66%);
  transform: translateX(-120%); transition: transform .9s var(--out);
}
.btn.primary:hover::after { transform: translateX(120%); }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent, #2997ff) 80%, white); outline-offset: 3px; border-radius: 8px; }

/* ---------- Zenith bar and panel: glass, with a thinking ring ---------- */
.kz-bar {
  background: var(--glass); border-color: var(--edge-hi);
  -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5);
  view-transition-name: kz-bar;
  transition: border-color .3s, box-shadow .4s var(--out);
}
.kz-bar:focus-within { border-color: color-mix(in srgb, var(--accent, #2997ff) 45%, var(--edge-hi)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, #2997ff) 14%, transparent), 0 18px 50px -20px rgba(0, 0, 0, .7); }
.kz-bar .mark, .brand .mark { position: relative; }
.kz-bar.thinking .mark::after, .brand.thinking .mark::after {
  content: ""; position: absolute; inset: -4px; border-radius: 9px; padding: 2px;
  background: conic-gradient(from var(--fx-a, 0deg), transparent 0 55%, rgba(var(--sun), .95), transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: fx-spin 1.1s linear infinite;
}
@property --fx-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes fx-spin { to { --fx-a: 360deg; } }
.kz-panel {
  background: var(--glass-hi); border-color: var(--edge-hi);
  -webkit-backdrop-filter: blur(26px) saturate(1.6); backdrop-filter: blur(26px) saturate(1.6);
  transform-origin: 85% 100%; animation: fx-panel .5s var(--glide) both;
}
@keyframes fx-panel { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.kz-msg { animation: fx-msg .45s var(--out) both; }
@keyframes fx-msg { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kz-toast { -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); background: var(--glass-hi); animation: fx-toast .5s var(--glide) both; }
@keyframes fx-toast { from { opacity: 0; transform: translate(-50%, 16px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- page transitions (Chromium/Edge, Safari 18.2+) ---------- */

::view-transition-group(root) { animation-duration: .5s; }
::view-transition-old(root) { animation: fx-vt-out .26s var(--out) both; }
::view-transition-new(root) { animation: fx-vt-in .5s var(--out) both; }
@keyframes fx-vt-out { to { opacity: 0; transform: scale(.992); filter: blur(3px); } }
@keyframes fx-vt-in { from { opacity: 0; transform: scale(1.006); } }
::view-transition-group(*) { animation-duration: .55s; animation-timing-function: var(--glide); }
::view-transition-old(*):not(:only-child), ::view-transition-new(*):not(:only-child) { animation-duration: .3s; }
::view-transition-group(kz-ambient), ::view-transition-group(kz-bar), ::view-transition-group(kz-brand) { animation-duration: .35s; }

/* ---------- command palette (Ctrl/Cmd+K) ---------- */
.fx-k-hint {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px 0 11px; border-radius: 999px;
  border: 1px solid var(--border, #232326); background: var(--card, #151517); color: var(--dim, #86868b); font: 12.5px 'Geist', system-ui, sans-serif; cursor: pointer;
  transition: border-color .2s, color .2s, background-color .2s;
}
.fx-k-hint:hover { color: var(--text); border-color: var(--border-hi, #38383d); }
.fx-k-hint kbd { font: 500 11px 'Geist Mono', monospace; color: var(--muted); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border-hi, #38383d); background: var(--card-2, #0f0f10); }
.fx-k { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: center; align-items: flex-start; padding: min(14vh, 120px) 16px 16px; }
.fx-k[hidden] { display: none !important; }
.fx-k .scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .42); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fx-fadein .3s var(--out) both; }
.fx-k .box {
  position: relative; width: min(660px, 100%); max-height: min(70vh, 620px); display: flex; flex-direction: column;
  background: var(--glass-hi); border: 1px solid var(--edge-hi); border-radius: 22px; overflow: hidden;
  -webkit-backdrop-filter: blur(28px) saturate(1.7); backdrop-filter: blur(28px) saturate(1.7);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .85), 0 0 0 1px rgba(0, 0, 0, .4);
  animation: fx-kbox .45s var(--glide) both; transform-origin: 50% 0;
}
.fx-k.closing .box { animation: fx-kbox-out .18s var(--out) both; }
.fx-k.closing .scrim { animation: fx-fadeout .2s var(--out) both; }
@keyframes fx-kbox { from { opacity: 0; transform: translateY(-10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fx-kbox-out { to { opacity: 0; transform: scale(.98); } }
@keyframes fx-fadein { from { opacity: 0; } }
@keyframes fx-fadeout { to { opacity: 0; } }
.fx-k .in { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--edge); }
.fx-k .in svg { color: var(--dim, #86868b); flex-shrink: 0; }
.fx-k .in input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text); font: 450 18px 'Geist', system-ui, sans-serif; letter-spacing: -0.01em; }
.fx-k .in input::placeholder { color: var(--dim, #86868b); }
.fx-k .in .esc { font: 500 11px 'Geist Mono', monospace; color: var(--dim, #86868b); padding: 3px 7px; border-radius: 6px; border: 1px solid var(--border-hi, #38383d); }
.fx-k .list { overflow-y: auto; padding: 6px 8px 10px; position: relative; overscroll-behavior: contain; }
.fx-k .grp { padding: 12px 10px 6px; font-size: 12px; color: var(--dim, #86868b); font-weight: 550; }
.fx-k .row {
  position: relative; z-index: 1; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 9px 10px; border-radius: 12px; cursor: pointer; color: var(--soft, #d2d2d7); font-size: 14.5px;
  animation: fx-msg .35s var(--out) both; animation-delay: calc(var(--i, 0) * 12ms);
}
.fx-k .row .ico { width: 22px; height: 22px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--card-2, #0f0f10); border: 1px solid var(--border, #232326); }
.fx-k .row .ico .dot { width: 8px; height: 8px; }
.fx-k .row .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-k .row .t mark { background: none; color: var(--text); font-weight: 650; }
.fx-k .row .m { font-size: 12px; color: var(--dim, #86868b); white-space: nowrap; }
.fx-k .row[aria-selected="true"] { color: var(--text); }
.fx-k .row[aria-selected="true"] .ico { color: var(--text); border-color: var(--border-hi, #38383d); }
.fx-k .hl { position: absolute; left: 8px; right: 8px; top: 0; height: 40px; border-radius: 12px; z-index: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(var(--sun), .16), rgba(255, 255, 255, .06)); border: 1px solid var(--edge-hi);
  transition: transform .32s var(--glide), height .32s var(--glide), opacity .2s; }
.fx-k .empty { padding: 26px 18px; color: var(--dim, #86868b); font-size: 14px; }
.fx-k .foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--edge); font-size: 12px; color: var(--dim, #86868b); }
.fx-k .foot kbd { font: 500 11px 'Geist Mono', monospace; color: var(--muted); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border-hi, #38383d); margin-right: 5px; }

/* ---------- small things that answer an action ---------- */
@keyframes fx-pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fx-burst { from { transform: translate(-50%, -50%) rotate(var(--r)) translateY(0) scale(1); opacity: 1; } to { transform: translate(-50%, -50%) rotate(var(--r)) translateY(-22px) scale(.2); opacity: 0; } }
.fx-burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 3; }
.fx-burst i { position: absolute; left: 0; top: 0; width: 5px; height: 5px; border-radius: 50%; background: var(--c, var(--ok, #1fbf9f)); animation: fx-burst .65s var(--out) both; }
.fx-skel { position: relative; overflow: hidden; background: var(--card-2, #0f0f10); border-radius: 10px; }
.fx-skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .045), transparent); animation: fx-shimmer 1.6s ease-in-out infinite; }
@keyframes fx-shimmer { to { transform: translateX(100%); } }

/* Masterclass pages: the sticky tab bar turns to frosted glass instead of a dark band across the light. */
.tk-bar {
  background: linear-gradient(color-mix(in srgb, var(--bg) 78%, transparent) 72%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent);
}

/* ---------- Home: what moves when ---------- */
/* On arrival one sweep of light runs round the Moment card (the one thing to do), then it rests. */
@property --fx-sweep { syntax: "<angle>"; inherits: false; initial-value: -90deg; }
.hero::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none; z-index: 2;
  background: conic-gradient(from var(--fx-sweep), transparent 0deg, rgba(var(--sun), .9) 40deg, rgba(var(--sun), 0) 95deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; animation: fx-sweep 2.6s .55s var(--out) 1 both;
}
@keyframes fx-sweep { 0% { --fx-sweep: -90deg; opacity: 0; } 12% { opacity: 1; } 80% { opacity: .9; } 100% { --fx-sweep: 300deg; opacity: 0; } }
#trials-card { view-transition-name: trials-hero; }
#reps-card { view-transition-name: reps-stage; }
.subject-row .cells span { animation: fx-cell .55s var(--glide) both; animation-delay: calc(var(--c, 0) * 7ms + 260ms); }
@keyframes fx-cell { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: none; } }
html.settled .subject-row .cells span { animation: none; }
.todo-row { overflow: hidden; transition: opacity .3s, height .42s var(--out), padding .42s var(--out), border-color .3s; }
.todo-row.has-focus { grid-template-columns: 22px minmax(0, 1fr) auto; }
.todo-row .focus-go {
  align-self: center; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1px solid var(--border-hi, #38383d); background: var(--card-2, #0f0f10); opacity: 0; transform: scale(.85);
  transition: opacity .25s, transform .35s var(--glide), color .2s, border-color .2s, background-color .2s;
}
.todo-row:hover .focus-go, .todo-row .focus-go:focus-visible { opacity: 1; transform: none; }
.todo-row .focus-go:hover { color: var(--bg); background: var(--text); border-color: var(--text); }
@media (hover: none) { .todo-row .focus-go { opacity: 1; transform: none; } }
.todo-row .tick svg path { stroke-dasharray: 24; stroke-dashoffset: 0; }
.todo-row.ticked .tick { animation: fx-pop .5s var(--pop) both; }
.todo-row.ticked .tick svg path { animation: fx-draw .45s .08s var(--out) both; }
@keyframes fx-draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
.todo-row.ticked .text { text-decoration: none; background: linear-gradient(currentColor, currentColor) no-repeat 0 55% / 100% 1px; animation: fx-strike .45s var(--out) both; }
@keyframes fx-strike { from { background-size: 0 1px; } to { background-size: 100% 1px; } }
.todo-row.leaving { opacity: 0; height: 0 !important; padding-top: 0; padding-bottom: 0; border-color: transparent; }
.stat-row .big .num, .h-card .big .num { display: inline-block; }
.dayline .nowmark { box-shadow: 0 0 0 3px rgba(var(--sun), .18), 0 0 14px rgba(var(--sun), .55); }

@media (prefers-reduced-motion: reduce) {
  .subject-row .cells span, .todo-row.ticked .tick, .todo-row.ticked .tick svg path, .todo-row.ticked .text, .hero::after, .rp-deck-card { animation: none !important; }
  .todo-row { transition: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .fx-ambient .sun, .fx-ambient .bloom, .card.reveal, .fx-in, .fx-w, .kz-panel, .kz-msg, .kz-toast, .fx-k .box, .fx-k .scrim, .fx-k .row, .fx-burst i, .fx-skel::after { animation: none !important; }
  .fx-roll .s, .fx-k .hl, a.go, .btn { transition: none !important; }
  a.go:hover { transform: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
.fx-k-hint .ico { display: none; }
.fx-k-hint .ico svg { width: 15px; height: 15px; }
@media (max-width: 1180px) { .fx-k-hint .lbl { display: none; } }
@media (hover: none), (max-width: 700px) { .fx-k-hint kbd { display: none; } .fx-k-hint .ico { display: inline-flex; } .fx-k-hint { padding: 0 10px; } }
