word/memory: celebration pause after each rotation
[sheet.git] / word / memory.plp
index 1bb8cebb3ae6211b609e4bf14fa513ef4776410a..7bf757f6cc76d44a17c92d297a178b9c34f22ca9 100644 (file)
@@ -1,11 +1,25 @@
 <(../common.inc.plp)><:
 
+our $wordlistbase;
+
 Html({
        raw => <<'EOT',
 <script src="/word/put.min.js"></script>
+<script src="/word/quiz.js"></script>
 <script src="/word/memory.js"></script>
 <style>
 /* cards */
+#quiz {
+       display: grid;
+       grid: repeat(3, 1fr) / repeat(4, 1fr);
+       grid-gap: 1ex;
+       min-height: calc(100vh - 11.5ex);
+}
+@media (orientation: portrait) {
+       #quiz {
+               grid: repeat(6, 1fr) / repeat(2, 1fr);
+       }
+}
 html {
        overflow: hidden; /* rotation overflow on celebration */
 }
@@ -14,9 +28,7 @@ figure {
        display: inline-block;
        background: #224;
        border: 1px solid #888;
-       margin: 2px;
        perspective: 100em;
-       height: 300px;
        position: relative;
 }
 figure:not(.turn):hover {
@@ -28,18 +40,22 @@ figure, img {
 
 /* card faces */
 figure img {
-       height: 100%;
-       width: auto;
        backface-visibility: hidden;
        transform: rotateY(180deg); /* back */
        transform-style: preserve-3d;
-       float: left; /* ff workaround to prevent click selection */
+       -float: left; /* ff workaround to prevent click selection */
+}
+figure.mirror img {
+       transform: rotateY(180deg) scaleX(-1);
 }
 
 /* turn results */
 figure.turn img {
        transform: rotateY(0deg);
 }
+figure.mirror.turn img {
+       transform: rotateY(0deg) scaleX(-1);
+}
 figure.bad img {
        filter: sepia(.5) hue-rotate(-45deg) saturate(2); /* red tint */
 }
@@ -48,16 +64,19 @@ figure.good {
 }
 
 .good figure {
-       animation: celebration 5s linear infinite;
+       animation: celebration 7s linear infinite;
        background: none;
        border: 0;
+       opacity: 1;
 }
 @keyframes celebration {
        0% { filter: hue-rotate(0deg); transform: rotate(0deg) }
-       50% { filter: hue-rotate(180deg); transform: rotate(180deg) }
+       33% { filter: hue-rotate(180deg); transform: rotate(180deg) }
+       66% { filter: hue-rotate(360deg); transform: rotate(360deg) }
        100% { filter: hue-rotate(360deg); transform: rotate(360deg) }
 }
 </style>
 EOT
 });
 say '<h1>memory</h1><p id="quiz"></p>';
+say "<script>new WordMemory('/$wordlistbase.json')</script>";