/* Memory: the card grid. A card is a button with a face and a back; the turn is a short flip, skipped when motion is reduced. */ .mm-grid { --cols: 4; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--sp-2); width: min(100%, 440px); } .mm-card { position: relative; aspect-ratio: 1; padding: 0; border: 0; background: transparent; cursor: pointer; touch-action: manipulation; border-radius: var(--r-sheet); } /* The turn is a squash and unsquash (a real 3D flip is flattened inside a button in Safari). */ .mm-inner { position: absolute; inset: 0; } .mm-card[data-up="true"][data-flip="1"] .mm-inner { animation: mm-up 0.28s ease-out; } .mm-card[data-up="false"][data-flip="1"] .mm-inner { animation: mm-down 0.28s ease-out; } @keyframes mm-up { from { transform: scaleX(0.1); } } @keyframes mm-down { from { transform: scaleX(0.1); } } .mm-face, .mm-back { position: absolute; inset: 0; border-radius: var(--r-sheet); display: grid; place-items: center; } /* A card back is felt (a material), so sixteen of them are quiet; the one amber thing on the page stays the primary button. */ .mm-back { background: var(--felt); border: 2px solid var(--felt-deep); background-image: repeating-linear-gradient(45deg, var(--felt-line) 0 7px, transparent 7px 14px); } .mm-back::after { content: "?"; font: 800 var(--fs-display) var(--font); color: rgba(255, 255, 255, 0.7); } .mm-face { visibility: hidden; background: var(--card); border: 2px solid var(--line); padding: 10%; } .mm-card[data-up="true"] .mm-face { visibility: visible; } .mm-card[data-up="true"] .mm-back { visibility: hidden; } .mm-face svg { width: 100%; height: 100%; display: block; } .mm-card[data-done="true"] .mm-face { border-color: var(--ok); background: var(--card); } .mm-card[data-done="true"] { cursor: default; } /* Only where there is a pointer to hover with: a finger leaves no hover, but a touch screen keeps :hover on the last card tapped. */ @media (hover: hover) { .mm-card:not([data-done="true"]):hover .mm-back { border-color: var(--accent); } } @media (prefers-reduced-motion: reduce) { html:not([data-anim="normal"]):not([data-anim="fast"]) .mm-inner { animation: none !important; } } :root[data-anim="off"] .mm-inner { animation: none !important; } .mm-players { justify-content: center; margin: 0; } .mm-names { display: grid; gap: var(--sp-2); } .mm-name { width: 100%; min-height: var(--target); padding: 0 var(--sp-3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; } /* A match settles with a small lift; a miss shows red until the pair turns back; a finished table lifts card by card. */ .mm-grid.still .mm-inner { animation: none; } .mm-card[data-done="true"] .mm-face { animation: mm-match 0.36s ease-out; } .mm-card[data-miss="true"] .mm-face { border-color: var(--bad); } .mm-grid.won .mm-face { animation: mm-match 0.5s ease-out both; animation-delay: calc(var(--k) * 45ms); } @keyframes mm-match { 0% { scale: 1; } 40% { scale: 1.1; } 100% { scale: 1; } } @media (prefers-reduced-motion: reduce) { html:not([data-anim="normal"]):not([data-anim="fast"]) .mm-card[data-done="true"] .mm-face, html:not([data-anim="normal"]):not([data-anim="fast"]) .mm-grid.won .mm-face { animation: none; } } :root[data-anim="off"] :is(.mm-card[data-done="true"] .mm-face, .mm-grid.won .mm-face) { animation: none; }