Files
2026-08-11 09:53:42 -04:00

289 lines
7.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Side Cards — Five-Card Deal</title>
<style>
:root {
--card-w: 110px;
--card-h: 154px;
--felt: #0b6b3a;
--felt-dark: #074d28;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-family: "Georgia", "Times New Roman", serif;
background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
color: #fff;
padding: 24px;
gap: 40px;
}
h1 {
font-size: 28px;
letter-spacing: 1px;
text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.area-label {
font-size: 14px;
letter-spacing: 3px;
text-transform: uppercase;
opacity: 0.75;
}
/* ---------- Cards ---------- */
.card {
width: var(--card-w);
height: var(--card-h);
border-radius: 4.8% / 3.4286%;
position: relative;
flex-shrink: 0;
box-shadow:
0 1px 0 rgba(130,125,116,0.78),
0 2px 3px rgba(0,0,0,0.28),
0 7px 14px rgba(0,0,0,0.32);
user-select: none;
overflow: hidden;
}
.card img {
width: 100%;
height: 100%;
display: block;
border-radius: 4.8% / 3.4286%;
}
.card::after,
.deck-card--top::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
background: linear-gradient(118deg,
rgba(0,0,0,0) 0%,
rgba(0,0,0,0) 62%,
rgba(0,0,0,0.025) 82%,
rgba(0,0,0,0.050) 100%);
}
/* ---------- Dealt hand ---------- */
.hand {
display: flex;
gap: 16px;
}
/* ---------- Deck stack ---------- */
.deck-wrap {
position: relative;
width: var(--card-w);
height: var(--card-h);
}
/* The cards under the top one are plain ivory stock -- never copies of the
back artwork, which reads as loose sheets rather than a deck. Each is
offset AND rotated a fraction of a degree more than the one above it, so
the stack looks hand-squared instead of machine-extruded. That tiny
rotation is why these are real elements and not box-shadow steps. */
.deck-under {
position: absolute;
inset: 0;
border-radius: 4.8% / 3.4286%;
background: linear-gradient(178deg, #fffdf8 0%, #f2ecdd 45%, #ded7c3 100%);
box-shadow:
0 1px 0 rgba(120,104,74,0.35),
0 2px 3px -2px rgba(0,0,0,0.5);
}
/* Contact shadow on the table, not on the card. A soft ellipse reads far
better than a rectangular drop shadow under a rounded object. */
.deck-ground {
position: absolute;
left: 50%;
bottom: -7px;
width: 116%;
height: 15px;
transform: translateX(-50%);
border-radius: 50%;
background: radial-gradient(50% 50% at 50% 50%,
rgba(0,0,0,0.5), transparent 72%);
filter: blur(2px);
pointer-events: none;
}
.deck-card {
position: absolute;
inset: 0;
border-radius: 4.8% / 3.4286%;
overflow: hidden;
box-shadow:
0 1px 1px rgba(0,0,0,0.24),
0 8px 14px -7px rgba(0,0,0,0.60),
0 21px 28px -16px rgba(0,0,0,0.55),
inset 0 0 0 1px rgba(255,255,255,0.92);
}
.deck-card img {
width: 100%;
height: 100%;
display: block;
border-radius: 4.8% / 3.4286%;
}
.deck-count {
position: absolute;
bottom: -34px;
left: 0;
right: 0;
text-align: center;
font-size: 14px;
letter-spacing: 2px;
opacity: 0.85;
}
.controls {
display: flex;
gap: 12px;
}
.controls button {
background: rgba(255,255,255,0.12);
color: #fff;
border: 1px solid rgba(255,255,255,0.35);
border-radius: 8px;
padding: 10px 20px;
font-size: 14px;
letter-spacing: 1px;
cursor: pointer;
transition: background 0.15s, transform 0.1s;
font-family: inherit;
}
.controls button:hover { background: rgba(255,255,255,0.22); }
.controls button:active { transform: translateY(1px); }
</style>
</head>
<body>
<h1>Side Cards</h1>
<div style="display:flex; flex-direction:column; align-items:center; gap:10px;">
<span class="area-label">Dealt Hand</span>
<div class="hand" id="hand"></div>
</div>
<div style="display:flex; flex-direction:column; align-items:center; gap:10px;">
<span class="area-label">Deck</span>
<div class="deck-wrap" id="deck"></div>
</div>
<div class="controls">
<button onclick="deal()">Deal Again</button>
<button onclick="reshuffle()">Reshuffle & Deal</button>
</div>
<script>
// Final self-contained Side Cards exports. Run @sideCards/tools/build_deck.py
// after changing any deck artwork or geometry.
const BASE = "@sideCards/exports/cards/";
const ASSET_VERSION = "20260805k";
const BACK = BASE + "back.svg?v=" + ASSET_VERSION;
const SUITS = [
{ code: "s", sym: "♠", color: "black" },
{ code: "h", sym: "♥", color: "red" },
{ code: "d", sym: "♦", color: "red" },
{ code: "c", sym: "♣", color: "black" },
];
const RANKS = ["A","2","3","4","5","6","7","8","9","10","J","Q","K"];
let fullDeck = [];
let dealt = [];
let deck = [];
function buildDeck() {
const d = [];
for (const s of SUITS) {
for (const r of RANKS) {
const file = `${r.toLowerCase()}${s.code}.svg`;
d.push({ rank: r, suit: s.sym, color: s.color,
url: BASE + file + "?v=" + ASSET_VERSION });
}
}
return d;
}
function shuffle(arr) {
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr;
}
function cardEl(card) {
const wrap = document.createElement("div");
wrap.className = "card";
const img = document.createElement("img");
img.src = card.url;
img.alt = `${card.rank} of ${card.suit}`;
img.loading = "lazy";
wrap.appendChild(img);
return wrap;
}
function render() {
const handEl = document.getElementById("hand");
handEl.innerHTML = "";
for (const c of dealt) handEl.appendChild(cardEl(c));
const deckEl = document.getElementById("deck");
deckEl.innerHTML = "";
if (deck.length > 0) {
const layers = Math.min(11, Math.ceil(deck.length / 5));
const ground = document.createElement("div");
ground.className = "deck-ground";
deckEl.appendChild(ground);
// Deepest card first so the one nearest the top card paints last.
for (let i = layers; i >= 1; i--) {
const under = document.createElement("div");
under.className = "deck-under";
under.style.transform =
`translate(${(i * 0.28).toFixed(2)}px, ${(i * 0.58).toFixed(2)}px) ` +
`rotate(${(i * 0.09).toFixed(2)}deg)`;
deckEl.appendChild(under);
}
const back = document.createElement("div");
back.className = "deck-card deck-card--top";
const img = document.createElement("img");
img.src = BACK;
img.alt = "Card back";
back.appendChild(img);
deckEl.appendChild(back);
}
const count = document.createElement("div");
count.className = "deck-count";
count.textContent = deck.length + " cards remaining";
deckEl.appendChild(count);
}
function deal() {
if (deck.length < 5) return;
dealt = deck.splice(0, 5);
render();
}
function reshuffle() {
fullDeck = shuffle(buildDeck());
dealt = fullDeck.splice(0, 5);
deck = fullDeck;
render();
}
reshuffle();
</script>
</body>
</html>