/* The demos. Every loop is 8 s on the same timeline. Each element's resting
   style is its end state, so with reduced motion the demo shows the result. */
.demo {
  --d: 8s;
  height: 200px; padding: 18px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
  background: var(--bg); font-size: 15px;
}
.box { background: var(--card); border: var(--hair); border-radius: 14px; box-shadow: var(--shadow); padding: 8px 12px; }
.chip { display: inline-block; border-radius: 999px; padding: 1px 9px; font-weight: 800; font-size: 13px; }
.der { background: var(--blue); } .die { background: var(--red); } .das { background: var(--green); }
.muted { color: var(--sub); font-size: 13px; }
.s1 { animation: s1 var(--d) infinite; }
.s2 { animation: s2 var(--d) infinite; }
.s3 { animation: s3 var(--d) infinite; }
@keyframes s1 { 0%, 18% { opacity: 0; transform: translateY(8px); } 24%, 90% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes s2 { 0%, 36% { opacity: 0; transform: translateY(8px); } 42%, 90% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
@keyframes s3 { 0%, 54% { opacity: 0; transform: translateY(8px); } 60%, 90% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }

/* add: typing, then the filled-in fields, then saved */
.d-add .field { font-weight: 700; white-space: nowrap; animation: focus var(--d) infinite; }
.d-add .typed { display: inline-block; animation: type var(--d) infinite; }
@keyframes type { 0%, 4% { clip-path: inset(0 100% 0 0); } 18%, 100% { clip-path: inset(0 0 0 0); } }
@keyframes focus { 0%, 20% { background: #fff8d6; } 24%, 100% { background: var(--card); } }
.d-add .rows { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.d-add .saved { align-self: flex-start; background: var(--green); border-radius: 999px; font-weight: 800; padding: 3px 12px; }

/* games: six tiles, the highlight walks across them */
.d-games { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-content: center; }
.tile {
  border-radius: 14px; padding: 10px 6px 12px; font-size: 12px; font-weight: 800; text-align: center;
  line-height: 1.2; box-shadow: var(--press); animation: lift 6s infinite;
}
.tile:nth-child(2) { animation-delay: 1s; } .tile:nth-child(3) { animation-delay: 2s; }
.tile:nth-child(4) { animation-delay: 3s; } .tile:nth-child(5) { animation-delay: 4s; }
.tile:nth-child(6) { animation-delay: 5s; }
@keyframes lift { 0%, 16%, 100% { transform: none; box-shadow: var(--press); } 4%, 12% { transform: translateY(-4px) rotate(-2deg); box-shadow: var(--press), 0 8px 16px rgba(20,10,10,.14); } }

/* daily: card flips to the meaning, then "Good" is tapped */
.d-daily .card { height: 84px; display: grid; place-items: center; position: relative; animation: flip var(--d) infinite; }
.d-daily .face { position: absolute; font-weight: 800; font-size: 20px; }
.d-daily .front { opacity: 0; animation: front var(--d) infinite; }
.d-daily .back { animation: back var(--d) infinite; }
@keyframes flip { 0%, 22% { transform: none; } 26% { transform: scaleX(0); } 30%, 100% { transform: none; } }
@keyframes front { 0%, 26% { opacity: 1; } 26.1%, 100% { opacity: 0; } }
@keyframes back { 0%, 26% { opacity: 0; } 26.1%, 100% { opacity: 1; } }
.d-daily .rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.d-daily .rate span { border-radius: 12px; box-shadow: var(--press); font-size: 12px; font-weight: 800; text-align: center; padding: 7px 0 9px; }
.d-daily .good { animation: press var(--d) infinite; }
@keyframes press { 0%, 62%, 74%, 100% { transform: none; box-shadow: var(--press); } 66%, 70% { transform: translateY(2px); box-shadow: none; } }

/* sprint: three nouns, each answered with its gender */
.d-sprint .word { height: 70px; display: grid; place-items: center; position: relative; }
.d-sprint .word b { position: absolute; font-size: 24px; font-weight: 800; }
.d-sprint .w1 { opacity: 0; animation: w1 var(--d) infinite; }
.d-sprint .w2 { opacity: 0; animation: w2 var(--d) infinite; }
.d-sprint .w3 { animation: w3 var(--d) infinite; }
@keyframes w1 { 0%, 30% { opacity: 1; } 33%, 100% { opacity: 0; } }
@keyframes w2 { 0%, 33% { opacity: 0; } 36%, 63% { opacity: 1; } 66%, 100% { opacity: 0; } }
@keyframes w3 { 0%, 66% { opacity: 0; } 69%, 100% { opacity: 1; } }
.d-sprint .btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.d-sprint .btns span { border-radius: 12px; background: var(--card); box-shadow: var(--press); font-weight: 800; text-align: center; padding: 8px 0 10px; }
.d-sprint .b1 { animation: b1 var(--d) infinite; }
.d-sprint .b2 { animation: b2 var(--d) infinite; }
.d-sprint .btns .b3 { animation: b3 var(--d) infinite; background: var(--green); }
@keyframes b1 { 0%, 16%, 30%, 100% { background: var(--card); } 18%, 28% { background: var(--blue); } }
@keyframes b2 { 0%, 49%, 63%, 100% { background: var(--card); } 51%, 61% { background: var(--red); } }
@keyframes b3 { 0%, 82% { background: var(--card); } 84%, 100% { background: var(--green); } }

/* packs: tap the pack, it turns into "Added", the word count jumps */
.d-packs .count { position: relative; height: 22px; font-weight: 800; }
.d-packs .count span { position: absolute; left: 0; }
.d-packs .pack {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border-radius: 16px; padding: 12px 14px 14px; font-weight: 800; position: relative;
  background: var(--green); box-shadow: var(--press); animation: packbg var(--d) infinite;
}
@keyframes packbg {
  0%, 34% { background: var(--amber); transform: none; box-shadow: var(--press); }
  37% { transform: translateY(2px); box-shadow: none; }
  40%, 100% { background: var(--green); transform: none; box-shadow: var(--press); }
}
.swap { position: relative; display: inline-grid; }
.swap > * { grid-area: 1 / 1; }
.before { opacity: 0; animation: before var(--d) infinite; }
.after { animation: after var(--d) infinite; }
@keyframes before { 0%, 38% { opacity: 1; } 40%, 100% { opacity: 0; } }
@keyframes after { 0%, 38% { opacity: 0; } 40%, 100% { opacity: 1; } }

/* backup: the file travels from the phone into the Documents folder */
.d-backup { flex-direction: row; align-items: center; justify-content: space-between; }
.d-backup .end { width: 84px; text-align: center; font-size: 12px; font-weight: 700; display: grid; gap: 6px; justify-items: center; }
.phone { width: 42px; height: 70px; border: var(--hair); border-radius: 10px; background: var(--card); box-shadow: var(--shadow); position: relative; }
.phone::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: 5px; height: 3px; border-radius: 2px; background: var(--rule); }
.folder { width: 70px; height: 52px; border-radius: 0 10px 10px 10px; background: var(--amber); box-shadow: var(--press); position: relative; margin-top: 12px; }
.folder::before { content: ''; position: absolute; left: 0; top: -10px; width: 30px; height: 11px; border-radius: 6px 6px 0 0; background: var(--amber); }
.file {
  position: absolute; z-index: 1; top: 50%; left: calc(100% - 77px); margin-top: -24px;
  width: 34px; height: 42px; border: var(--hair); border-radius: 7px; background: var(--card); box-shadow: var(--shadow);
  display: grid; place-items: center; font-size: 10px; font-weight: 800;
  animation: travel var(--d) infinite;
}
@keyframes travel {
  0%, 18% { left: 43px; opacity: 0; }
  22% { left: 43px; opacity: 1; }
  50%, 90% { left: calc(100% - 77px); opacity: 1; }
  96%, 100% { opacity: 0; }
}
.d-backup .tick { position: absolute; left: 0; right: 0; bottom: 16px; margin: auto; width: max-content; }

/* owl: the study pal, reminder and icon demos take turns, one 6 s loop each.
   The scenes run all the time, so each one starts its loop as it shows.
   The strip under them names the three and fills while its scene plays.
   Demo 170 + strip 30 keeps the card as tall as the others */
.cycle > .demo, .scenes { --d: 6s; }
.cycle { display: grid; }
.cycle > .demo { height: 170px; padding-block: 12px; grid-area: 1 / 1; animation: cycle calc(var(--d) * 3) infinite; }
.cycle > .demo:nth-child(2), .cycle > .demo:nth-child(3) { opacity: 0; }
.cycle > :nth-child(2), .scenes :nth-child(2) i { animation-delay: calc(var(--d) * -2); }
.cycle > :nth-child(3), .scenes :nth-child(3) i { animation-delay: calc(var(--d) * -1); }
@keyframes cycle { 0%, 31% { opacity: 1; } 33.3%, 98% { opacity: 0; } 100% { opacity: 1; } }
.scenes { display: grid; grid-template-columns: repeat(3, 1fr); border-top: var(--hair); border-bottom: 1px solid var(--rule); }
.scenes span { position: relative; isolation: isolate; line-height: 28px; text-align: center; font-size: 12px; font-weight: 800; }
.scenes span + span { border-left: var(--hair); }
.scenes i { position: absolute; inset: 0 auto 0 0; z-index: -1; width: 0; background: var(--amber); animation: fill calc(var(--d) * 3) linear infinite; }
.scenes :first-child i { width: 100%; }
@keyframes fill { 0% { width: 0; } 33.3% { width: 100%; } 33.4%, 100% { width: 0; } }

/* study pal: the clock runs through a day, Daily fills, the owl changes with both */
.d-pal { flex-direction: row; align-items: center; gap: 14px; }
.d-pal .owl { width: 120px; flex: none; display: grid; }
.d-pal .owl img { grid-area: 1 / 1; width: 100%; height: auto; }
.d-pal .side { flex: 1; min-width: 0; display: grid; gap: 10px; }
.d-pal .side .swap { justify-self: start; }
.d-pal .clock b { border-radius: 12px; box-shadow: var(--press); padding: 2px 12px 4px; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.d-pal .row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.d-pal .bar { height: 10px; margin-top: 6px; border-radius: 999px; overflow: hidden; background: var(--surface); }
.d-pal .bar i { display: block; border-radius: 999px; height: 100%; width: 100%; background: var(--green); animation: palbar var(--d) infinite; }
.d-pal .p1, .d-pal .p2, .d-pal .p3, .d-pal .p23 { opacity: 0; }
.d-pal .p1 { animation: pal1 var(--d) infinite; }
.d-pal .p2 { animation: pal2 var(--d) infinite; }
.d-pal .p3 { animation: pal3 var(--d) infinite; }
.d-pal .p23 { animation: pal23 var(--d) infinite; }
.d-pal .p4 { animation: pal4 var(--d) infinite; }
@keyframes pal1 { 0% { opacity: 0; transform: scale(.85); } 3% { opacity: 1; transform: scale(1.06); } 5%, 23% { opacity: 1; transform: none; } 25%, 100% { opacity: 0; } }
@keyframes pal2 { 0%, 24% { opacity: 0; transform: scale(.85); } 27% { opacity: 1; transform: scale(1.06); } 29%, 48% { opacity: 1; transform: none; } 50%, 100% { opacity: 0; } }
@keyframes pal3 { 0%, 49% { opacity: 0; transform: scale(.85); } 52% { opacity: 1; transform: scale(1.06); } 54%, 73% { opacity: 1; transform: none; } 75%, 100% { opacity: 0; } }
@keyframes pal23 { 0%, 24% { opacity: 0; transform: scale(.85); } 27% { opacity: 1; transform: scale(1.06); } 29%, 73% { opacity: 1; transform: none; } 75%, 100% { opacity: 0; } }
@keyframes pal4 { 0%, 74% { opacity: 0; transform: scale(.85); } 77% { opacity: 1; transform: scale(1.06); } 79%, 96% { opacity: 1; transform: none; } 98%, 100% { opacity: 0; } }
@keyframes palbar {
  0%, 23% { width: 0; background: var(--amber); }
  27%, 48% { width: 50%; background: var(--amber); }
  52%, 73% { width: 50%; background: var(--red); }
  77%, 96% { width: 100%; background: var(--green); }
  100% { width: 0; background: var(--green); }
}

/* reminders: Daily still owed, each nudge replaces the one before, more worried each time.
   Like Android: text on the left, the reminder's app owl as the large icon on the right */
.d-notify { gap: 12px; }
.d-notify .swap { display: grid; }
.d-notify .now { align-self: center; font-size: 36px; font-weight: 800; font-variant-numeric: tabular-nums; }
.d-notify .note { display: flex; gap: 10px; align-items: center; border-radius: 18px; }
.d-notify .note p { flex: 1; font-size: 13px; color: var(--sub); line-height: 1.3; }
.d-notify .note b { display: block; font-size: 15px; color: var(--ink); }
.d-notify .note img { width: 58px; height: 50px; flex: none; object-fit: contain; }
.d-notify .n1, .d-notify .n2 { opacity: 0; }
.d-notify .n1 { animation: n1 var(--d) infinite; }
.d-notify .n2 { animation: n2 var(--d) infinite; }
.d-notify .n3 { animation: n3 var(--d) infinite; }
@keyframes n1 { 0% { opacity: 0; transform: translateY(-14px); } 4%, 30% { opacity: 1; transform: none; } 33%, 100% { opacity: 0; } }
@keyframes n2 { 0%, 33% { opacity: 0; transform: translateY(-14px); } 37%, 63% { opacity: 1; transform: none; } 66%, 100% { opacity: 0; } }
@keyframes n3 { 0%, 66% { opacity: 0; transform: translateY(-14px); } 70%, 96% { opacity: 1; transform: none; } 98%, 100% { opacity: 0; } }

/* dynamic icon: the launcher owl's face follows the clock while Daily is owed,
   then cheers once it's done. Eight slots of --d / 8; each .f gets its slot as --k */
.d-icon { flex-direction: row; align-items: center; gap: 18px; }
.d-icon .app { flex: none; display: grid; justify-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.d-icon .ico { width: 96px; height: 96px; display: grid; overflow: hidden; border-radius: 22%; background: #35195E; box-shadow: 0 6px 16px rgba(53,25,94,.3); }
.d-icon .ico img { grid-area: 1 / 1; width: 150%; margin: -25%; }
.d-icon .side { flex: 1; min-width: 0; display: grid; gap: 10px; justify-items: start; }
.d-icon .swap { justify-items: start; }
.d-icon .clock b { border-radius: 12px; box-shadow: var(--press); padding: 2px 12px 4px; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.d-icon .f, .d-icon .owed { opacity: 0; }
.d-icon .end { opacity: 1; }
.d-icon .f { animation: icf var(--d) calc(var(--d) * var(--k) / 8 - var(--d)) infinite; }
.d-icon .owed { animation: owed var(--d) infinite; }
@keyframes icf { 0% { opacity: 0; transform: scale(.85); } 2% { opacity: 1; transform: scale(1.08); } 4%, 12.5% { opacity: 1; transform: none; } 14%, 100% { opacity: 0; } }
@keyframes owed { 0% { opacity: 0; } 2%, 86% { opacity: 1; } 87.5%, 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .demo *, .demo, .scenes i { animation: none !important; }
}
