/* The generated /blackjack/ pages (site/tools/build_hands.py): a hand drawn in HTML, played by
   assets/hand-drawn.js, and the hub's chart. Loaded after home.css, on those pages only. */

/* ---------- a drawn hand ---------- */
.dhand { display: grid; justify-items: center; gap: 18px; margin: 28px 0 8px; }
.dh-felt {
  display: grid; justify-items: center; gap: clamp(28px, 8vw, 44px); width: 100%;
  padding: clamp(24px, 7vw, 40px) 0;
  background: radial-gradient(52% 50% at 50% 50%, rgba(40, 92, 66, .34), transparent 74%);
}
.dh-row { display: flex; }
.card {
  --w: clamp(66px, 19vw, 96px);
  position: relative; display: block; flex: none; width: var(--w); aspect-ratio: 5 / 7;
  border-radius: calc(var(--w) * .1); background: #f3eee6;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 6px 18px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
  color: #17191c; font-family: ui-serif, "New York", Georgia, serif; line-height: 1;
}
.card + .card { margin-left: calc(var(--w) * -.38); }
.card.red { color: #b4262f; }
.c-r { position: absolute; left: 11%; top: 8%; font-size: calc(var(--w) * .3); font-weight: 600; letter-spacing: -.04em; }
.c-s { position: absolute; left: 13%; top: 34%; font-size: calc(var(--w) * .2); }
.c-p { position: absolute; right: 12%; bottom: 12%; font-size: calc(var(--w) * .46); }
.card.back {
  background: #5a1d22;
  box-shadow: inset 0 0 0 calc(var(--w) * .07) #5a1d22, inset 0 0 0 calc(var(--w) * .08) rgba(227, 184, 98, .55),
    0 6px 18px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
}
.dh-dealer .card.back { margin-left: calc(var(--w) * -.62); }

/* the cards come in once, as dealt; transform and opacity only, so nothing around them moves */
@keyframes dh-in { from { opacity: 0; transform: translateY(-14px) rotate(-2deg); } }
html.js:not(.still) .dh-row .card { animation: dh-in .42s cubic-bezier(.2, .7, .2, 1) both; }
html.js:not(.still) .dh-dealer .card:nth-child(2) { animation-delay: .24s; }
html.js:not(.still) .dh-you .card:nth-child(1) { animation-delay: .12s; }
html.js:not(.still) .dh-you .card:nth-child(2) { animation-delay: .36s; }

/* the tray: the app's buttons, two on top and the rest below */
.dh-tray { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 440px; }
.dh-b {
  grid-column: span 2; min-height: 50px; padding: 0 8px; border: 0; border-radius: 999px;
  background: rgba(242, 234, 219, .08); color: var(--gold);
  font: 600 17px/1 var(--sans); letter-spacing: .01em; cursor: pointer;
  transition: background-color .2s ease, color .2s ease, opacity .2s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.dh-b:nth-child(-n+2) { grid-column: span 3; }
.dh-tray.n4 .dh-b:nth-child(n+3) { grid-column: span 3; }
.dh-b:hover { background: rgba(242, 234, 219, .14); }
.dh-b:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.dhand.played .dh-b { opacity: .45; }
.dhand.played .dh-b[aria-pressed="true"] { opacity: 1; background: rgba(242, 234, 219, .16); color: var(--ink); }
.dhand.played .dh-b.is-book { opacity: 1; background: var(--gold); color: var(--bg); }

/* the verdict: its space is held from the start by the longest line, so nothing moves */
.dh-words { display: grid; width: 100%; max-width: 520px; text-align: center; font-size: clamp(24px, 6.4vw, 32px); }
.dh-words > p { grid-area: 1 / 1; margin: 0; font-size: inherit; }
.dh-ghost { visibility: hidden; }
/* holds the verdict's room; in CSS so no page carries another hand's play in its text */
.dh-ghost::before { content: "Right.\A The book says surrender."; white-space: pre-line; }
.dh-verdict { opacity: 0; transition: opacity .25s ease; }
.dhand.played .dh-verdict { opacity: 1; }

html:not(.js) .dh-tray, html:not(.js) .dh-words { display: none; }
html.still .dh-b, html.still .dh-verdict { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .dh-row .card { animation: none !important; }
  .dh-b, .dh-verdict { transition: none; }
}

/* ---------- the hub ---------- */
.hub-grid { margin-top: 32px; display: grid; gap: 28px; }
.hub-chart { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 2px; font: 600 12px/1 var(--sans); }
.hub-chart caption { text-align: left; font-size: clamp(24px, 6vw, 32px); padding: 0 0 12px 2px; }
.hub-chart th { color: var(--ink-2); font-weight: 600; }
.hub-chart thead th { height: 28px; color: var(--ink); }
.hub-chart thead th:first-child { width: 2.9em; }
.hub-chart tbody th { text-align: left; padding-left: 2px; white-space: nowrap; color: var(--ink); }
.hub-chart td { height: 32px; padding: 0; text-align: center; border-radius: 5px; letter-spacing: -.02em; }
.hub-chart td a {
  display: grid; place-items: center; height: 100%; border-radius: inherit;
  color: var(--bg); background: var(--gold); text-decoration: none;
}
.hub-chart td a:hover { filter: brightness(1.12); color: var(--bg); }
.hub-chart td a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.h-hit { background: rgba(242, 234, 219, .07); color: var(--ink-2); }
.h-stand { background: rgba(242, 234, 219, .2); color: var(--ink); }
.h-dbl { background: rgba(62, 140, 98, .42); color: var(--ink); }
.h-split { background: rgba(70, 104, 190, .48); color: var(--ink); }
.h-sur { background: rgba(160, 52, 66, .55); color: var(--ink); }
.hub-key { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; padding: 0; list-style: none; font-size: 15px; color: var(--ink-2); }
.hub-key i { display: inline-grid; place-items: center; min-width: 26px; height: 22px; margin-right: 6px; padding: 0 4px; border-radius: 4px; font: 600 12px/1 var(--sans); }
.hub-grid p { margin: 0; }

@media (min-width: 700px) {
  .hub-chart { font-size: 14px; }
  .hub-chart td { height: 38px; }
  .hub-chart thead th:first-child { width: 3.6em; }
}
@media (min-width: 900px) {
  .dhand { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "felt tray" "felt words"; align-items: center; justify-items: stretch; column-gap: 48px; row-gap: 22px; }
  .dh-felt { grid-area: felt; }
  .dh-tray { grid-area: tray; align-self: end; }
  .dh-words { grid-area: words; align-self: start; text-align: left; font-size: 30px; }
}
