/* A Shade tabletop channel (TabletopHost.razor, js/tabletop.js): a felt with cards, dice, tokens, counters, boards and
   notes on it, a hand of cards along the bottom, and who is at the table down the side. The table and its pieces keep
   their own colours in either theme, as a real table would; everything round it follows the site's. */

/* ---- the channel: toolbar, table, side panel ---------------------------------------------------------------- */
.tt { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 15rem; background: var(--rl-surface); }
.tt__main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tt__tools { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .45rem .7rem; border-bottom: 1px solid var(--rl-border); background: var(--rl-surface-raised); }
.tt__tools .tt__spacer { flex: 1; }
.tt__notice { margin: 0; font-size: .85rem; color: var(--rl-text-muted); }
.tt__error { margin: 0; padding: .5rem .8rem; color: var(--rl-danger); }
.tt__dropWrap { position: relative; }
.tt__dropBack { position: fixed; inset: 0; z-index: 29; }
.tt__drop { position: absolute; left: 0; top: calc(100% + 4px); z-index: 30; display: grid; grid-template-columns: repeat(2, minmax(9.5rem, 1fr)); gap: .1rem .9rem; width: max-content; max-width: min(34rem, 92vw); max-height: min(70vh, 30rem); overflow: auto; padding: .6rem .7rem; background: var(--rl-surface-raised); border: 1px solid var(--rl-border); border-radius: var(--rl-radius); box-shadow: 0 12px 34px rgba(0, 0, 0, .28); }
.tt__drop--list { grid-template-columns: minmax(0, 1fr); width: 21rem; }
.tt__dropGroup { display: flex; flex-direction: column; break-inside: avoid; margin-bottom: .35rem; }
.tt__dropGroup h4 { margin: .15rem 0 .2rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--rl-text-muted); }
.tt__dropItem { display: block; width: 100%; padding: .3rem .45rem; text-align: left; font: inherit; color: var(--rl-text); background: none; border: 0; border-radius: .35rem; cursor: pointer; }
.tt__dropItem:hover, .tt__dropItem:focus-visible { background: var(--rl-surface-sunken); outline: none; }
.tt__dropItem small { display: block; color: var(--rl-text-muted); font-size: .78rem; }
.tt__help { grid-column: 1 / -1; margin: 0; font-size: .84rem; color: var(--rl-text); }
.tt__help dt { float: left; clear: left; min-width: 7.5rem; font-weight: 600; }
.tt__help dd { margin: 0 0 .28rem 7.8rem; color: var(--rl-text-muted); }

.tt__side { display: flex; flex-direction: column; gap: .35rem; min-height: 0; overflow: auto; padding: .8rem .9rem; border-left: 1px solid var(--rl-border); background: var(--rl-surface-raised); }
.tt__h { margin: .2rem 0 .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--rl-text-muted); }
.tt__who, .tt__log { list-style: none; margin: 0; padding: 0; }
.tt__person { display: flex; align-items: center; gap: .5rem; padding: .28rem 0; }
.tt__dot { flex: none; width: .7rem; height: .7rem; border-radius: 50%; box-shadow: 0 0 0 1px var(--rl-border); }
.tt__dot--away { background: transparent; box-shadow: 0 0 0 1px var(--rl-border-strong, var(--rl-border)); }
.tt__personName { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt__person--away .tt__personName { color: var(--rl-text-muted); }
.tt__held { flex: none; font-size: .78rem; color: var(--rl-text-muted); font-variant-numeric: tabular-nums; }
.tt__log li { padding: .22rem 0; font-size: .82rem; color: var(--rl-text-muted); border-top: 1px solid var(--rl-border); overflow-wrap: anywhere; }
.tt__log li:first-child { color: var(--rl-text); border-top: 0; }
.tt__hint { margin: .3rem 0 .5rem; font-size: .8rem; color: var(--rl-text-muted); }

/* ---- the table ---------------------------------------------------------------------------------------------- */
.tt__stage { position: relative; flex: 1; min-height: 16rem; overflow: hidden; background: var(--rl-surface-sunken); touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; outline: none; }
.tt__stage:active { cursor: grabbing; }
.tt__world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.tt__felt { position: absolute; left: 0; top: 0; border-radius: 36px; background: radial-gradient(ellipse at 50% 40%, #35755a 0%, #2a5f49 55%, #224d3b 100%); box-shadow: 0 0 0 14px #5a3d27, 0 0 0 18px #3b2717, 0 30px 80px rgba(0, 0, 0, .45), inset 0 0 120px rgba(0, 0, 0, .35); }
.tt__marquee { position: absolute; z-index: 5; border: 1px dashed var(--rl-accent); background: color-mix(in srgb, var(--rl-accent) 14%, transparent); pointer-events: none; }
.tt__ui { cursor: default; user-select: auto; -webkit-user-select: auto; }

.tt__bar { position: absolute; left: 50%; top: 3.2rem; z-index: 12; transform: translateX(-50%); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .3rem; width: max-content; max-width: calc(100% - 1.1rem); padding: .3rem .45rem; background: var(--rl-surface-raised); border: 1px solid var(--rl-border); border-radius: var(--rl-radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.tt__bar[hidden], .tt__hand[hidden], .tt__toast[hidden], .tt__marquee[hidden] { display: none; }
.tt__barCount { max-width: 14rem; padding: 0 .3rem; font-size: .8rem; color: var(--rl-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt__zoom { position: absolute; right: .55rem; top: .55rem; z-index: 11; display: flex; align-items: center; gap: .25rem; padding: .25rem; background: color-mix(in srgb, var(--rl-surface-raised) 92%, transparent); border: 1px solid var(--rl-border); border-radius: var(--rl-radius); }
.tt__zoom .btn[aria-pressed="true"] { background: var(--rl-accent); color: var(--rl-accent-contrast); border-color: transparent; }
.tt__zoomPct { min-width: 2.8rem; text-align: center; font-size: .8rem; color: var(--rl-text-muted); font-variant-numeric: tabular-nums; }
.tt__toast { position: absolute; left: 50%; bottom: 9.5rem; z-index: 40; transform: translateX(-50%); max-width: min(30rem, 90%); padding: .5rem .8rem; color: #fff; background: rgba(20, 20, 24, .92); border-radius: var(--rl-radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); font-size: .9rem; text-align: center; }

.tt__menu { position: absolute; z-index: 45; display: flex; flex-direction: column; min-width: 13rem; max-height: calc(100% - 8px); overflow: auto; padding: .3rem; background: var(--rl-surface-raised); border: 1px solid var(--rl-border); border-radius: var(--rl-radius); box-shadow: 0 12px 34px rgba(0, 0, 0, .3); }
.tt__menuItem { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; padding: .32rem .55rem; font: inherit; color: var(--rl-text); text-align: left; background: none; border: 0; border-radius: .35rem; cursor: pointer; }
.tt__menuItem:hover, .tt__menuItem:focus-visible { background: var(--rl-surface-sunken); outline: none; }
.tt__menuItem.is-danger { color: var(--rl-danger); }
.tt__menuItem kbd { font: inherit; font-size: .74rem; color: var(--rl-text-muted); background: none; border: 0; padding: 0; box-shadow: none; }

.tt__sheet { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(10, 10, 14, .45); }
.tt__sheetCard { display: flex; flex-direction: column; gap: .6rem; width: min(26rem, 100%); max-height: 100%; overflow: auto; padding: .9rem 1rem; color: var(--rl-text); background: var(--rl-surface-raised); border: 1px solid var(--rl-border); border-radius: var(--rl-radius); box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.tt__sheetTitle { margin: 0; font-size: 1rem; }
.tt__sheetText { margin: 0; color: var(--rl-text-muted); }
.tt__sheetBtns { display: flex; justify-content: flex-end; gap: .4rem; }
.tt__form { display: flex; flex-direction: column; gap: .55rem; }
.tt__field { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--rl-text-muted); }
.tt__field input, .tt__field textarea, .tt__field select { width: 100%; padding: .35rem .5rem; font: inherit; font-size: .95rem; color: var(--rl-text); background: var(--rl-surface); border: 1px solid var(--rl-border); border-radius: .4rem; }
.tt__field textarea { resize: vertical; min-height: 4rem; }
.tt__field small { font-size: .76rem; }
.tt__swatches { display: flex; flex-wrap: wrap; gap: .35rem; }
.tt__swatch { width: 1.6rem; height: 1.6rem; padding: 0; border: 2px solid var(--rl-border); border-radius: 50%; cursor: pointer; }
.tt__swatch.is-on { border-color: var(--rl-text); box-shadow: 0 0 0 2px var(--rl-accent); }
.tt__cards { display: flex; flex-wrap: wrap; gap: .4rem; max-height: 50vh; overflow: auto; padding: .2rem; }
.tt__cardPick { padding: 0; background: none; border: 0; border-radius: 7px; cursor: pointer; }
.tt__cardPick:hover .tt__mini, .tt__cardPick:focus-visible .tt__mini { box-shadow: 0 0 0 2px var(--rl-accent); }

/* ---- the hand ----------------------------------------------------------------------------------------------- */
.tt__hand { position: absolute; left: .55rem; right: .55rem; bottom: .55rem; z-index: 10; display: flex; flex-direction: column; gap: .3rem; padding: .4rem .55rem .5rem; background: color-mix(in srgb, var(--rl-surface-raised) 94%, transparent); border: 1px solid var(--rl-border); border-radius: var(--rl-radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.tt__hand.is-target { border-color: var(--rl-accent); box-shadow: 0 0 0 2px var(--rl-accent), 0 8px 24px rgba(0, 0, 0, .25); }
.tt__handHead { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; font-size: .82rem; color: var(--rl-text-muted); }
.tt__handTitle { color: var(--rl-text); }
.tt__handHint { flex: 1; min-width: 8rem; }
.tt__handTitle + .tt__handHint[hidden] + .tt__check { margin-left: auto; }
.tt__check { display: inline-flex; align-items: center; gap: .3rem; margin: 0; cursor: pointer; white-space: nowrap; }
.tt__handRow { display: flex; gap: .3rem; min-height: 0; overflow-x: auto; padding: 2px 2px 4px; touch-action: pan-x; }
.tt__handRow:empty { display: none; }
.tt__hcard { flex: none; cursor: grab; transition: transform .08s ease-out; }
.tt__hcard:hover { transform: translateY(-3px); }
.tt__hcard.is-on { transform: translateY(-7px); box-shadow: 0 0 0 2px var(--rl-accent), 0 4px 10px rgba(0, 0, 0, .3); }
.tt__ghost { position: absolute; z-index: 60; transform: translate(-50%, -50%) rotate(-4deg); pointer-events: none; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .4)); }

/* ---- pieces ------------------------------------------------------------------------------------------------- */
.tp { position: absolute; left: 0; top: 0; box-sizing: border-box; cursor: grab; font-family: system-ui, "Segoe UI", "Segoe UI Symbol", "Segoe UI Emoji", sans-serif; }
.tp.is-locked { cursor: inherit; }
.tp.is-glide { transition: transform .09s linear; }
.tp.is-carried { cursor: grabbing; filter: drop-shadow(0 9px 10px rgba(0, 0, 0, .4)); }
.tp.is-sel { outline: 2px solid var(--rl-accent); outline-offset: 3px; border-radius: 7px; }
.tp.is-held { outline: 2px dashed var(--tt-holder, #fff); outline-offset: 3px; border-radius: 7px; }
.tp.is-held[data-by]:not([data-by=""])::after { content: attr(data-by); position: absolute; left: 0; bottom: calc(100% + 6px); padding: 0 .35em; font: 600 12px/1.5 system-ui, sans-serif; color: #fff; white-space: nowrap; background: rgba(15, 15, 18, .82); border-left: 3px solid var(--tt-holder, #fff); border-radius: 3px; pointer-events: none; }
.tp__body { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; box-sizing: border-box; overflow: hidden; }
.tp__count { position: absolute; right: -7px; top: -9px; min-width: 20px; height: 20px; padding: 0 5px; box-sizing: border-box; font: 700 11px/20px system-ui, sans-serif; color: #fff; text-align: center; background: #1b1a18; border-radius: 10px; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .7); pointer-events: none; }

/* cards: the same face on the table, in the hand and in a peek */
.tp--card .tp__body { border-radius: 7px; box-shadow: calc(var(--tt-thick, 0) * .45px) calc(var(--tt-thick, 0) * .45px) 0 0 #b3ad9f, 0 1px 3px rgba(0, 0, 0, .45); }
.tp__face, .tt__mini { color: #1b1a18; background: #fbfaf6; font-size: 16px; line-height: 1; }
.tp__face.is-red, .tt__mini.is-red { color: #c2261f; }
/* Reason: only the small card is positioned here. A card on the table is its piece's body, which already fills the piece;
   making that one relative as well would let it shrink to its words. */
.tt__mini { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 60px; height: 86px; box-sizing: border-box; overflow: hidden; font-size: 13.5px; font-family: system-ui, "Segoe UI", "Segoe UI Symbol", sans-serif; border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .45); user-select: none; -webkit-user-select: none; }
.tt__mini--tile { width: 44px; flex-direction: column; background: #f3eede; }
.tp__corner { position: absolute; display: flex; flex-direction: column; align-items: center; gap: .08em; font-size: .95em; }
.tp__corner b { font-weight: 700; letter-spacing: -.04em; }
.tp__corner i { font-style: normal; font-size: .9em; }
.tp__corner--a { left: .32em; top: .32em; }
.tp__corner--b { right: .32em; bottom: .32em; transform: rotate(180deg); }
.tp__pip { font-size: 2.3em; }
.tp__words { padding: .35em; text-align: center; line-height: 1.15; overflow-wrap: anywhere; white-space: pre-wrap; }
.tp--tile .tp__face { flex-direction: column; background: #f3eede; }
.tp__half { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 2.6em; line-height: 1; }
.tp__bar { flex: none; width: 70%; height: 2px; background: currentColor; opacity: .7; }
.tp__back { border: 4px solid #fbfaf6; background-color: var(--tt-back, #2456a6); background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .17) 0 4px, transparent 4px 8px), repeating-linear-gradient(-45deg, rgba(255, 255, 255, .17) 0 4px, transparent 4px 8px); }
.tp__back > * { display: none; }
.tp__back--blue { --tt-back: #2456a6; }
.tp__back--red { --tt-back: #a8322d; }
.tp__back--green { --tt-back: #23764a; }
.tp__back--black { --tt-back: #26242a; }
.tp__back--gold { --tt-back: #b8892b; }
.tp__back--tile { border: 1px solid #cfc8b6; background: #efe9da; background-image: none; }
.tp--card.is-rolling .tp__body { animation: tt-shuffle .42s ease-in-out; }
@keyframes tt-shuffle { 0%, 100% { transform: none; } 20% { transform: translateX(-6px) rotate(-4deg); } 50% { transform: translateX(6px) rotate(4deg); } 80% { transform: translateX(-3px) rotate(-2deg); } }

/* dice */
.tp--die .tp__body { color: #fff; font-weight: 700; font-size: 21px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.tp--d6 .tp__body { color: #1b1a18; background: #f6f3eb; border-radius: 18%; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .14); font-size: 26px; }
.tp--d2 .tp__body { color: #4a3708; background: radial-gradient(circle at 35% 30%, #f6dc86, #c99a2b); border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(74, 55, 8, .35); }
.tp--d4 .tp__body { background: #2f9e5b; clip-path: polygon(50% 3%, 97% 93%, 3% 93%); padding-top: 34%; }
.tp--d8 .tp__body { background: #2e7dd1; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.tp--d10 .tp__body { background: #8e5bd0; clip-path: polygon(50% 0, 97% 42%, 50% 100%, 3% 42%); padding-bottom: 10%; }
.tp--d12 .tp__body { background: #d98b1f; clip-path: polygon(50% 0, 100% 38%, 81% 100%, 19% 100%, 0 38%); padding-top: 8%; }
.tp--d20 .tp__body { background: #d64541; clip-path: polygon(50% 0, 94% 25%, 94% 75%, 50% 100%, 6% 75%, 6% 25%); }
.tp--d100 .tp__body { background: #2b2927; border-radius: 50%; font-size: 17px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25); }
.tp__sides { position: absolute; left: 50%; top: calc(100% + 1px); transform: translateX(-50%); font: 600 10px/1 system-ui, sans-serif; color: rgba(255, 255, 255, .78); text-shadow: 0 1px 2px rgba(0, 0, 0, .7); pointer-events: none; }
.tp--die.is-rolling .tp__body { animation: tt-roll .5s cubic-bezier(.3, .7, .3, 1); }
@keyframes tt-roll { 0% { transform: rotate(0) scale(1); } 45% { transform: rotate(250deg) scale(1.3); } 100% { transform: rotate(720deg) scale(1); } }

/* tokens */
.tp--token .tp__body { font-weight: 700; line-height: 1; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .22), inset 0 0 0 2px rgba(255, 255, 255, .22), 0 1px 3px rgba(0, 0, 0, .5); }
.tp--token.tp--disc .tp__body, .tp--token.tp--chip .tp__body { border-radius: 50%; }
.tp--token.tp--square .tp__body { border-radius: 16%; }
.tp--token.tp--hex .tp__body { clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%); box-shadow: none; }
.tp--token.tp--chip .tp__body { border: 4px dashed rgba(255, 255, 255, .75); box-shadow: 0 0 0 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .5); }
.tp--token.tp--glyph .tp__body { overflow: visible; font-weight: 400; box-shadow: none; text-shadow: 0 0 2px #000, 0 1px 3px rgba(0, 0, 0, .6); }
.tp--token.tp--glyph .tp__body.is-dark { text-shadow: 0 0 2px #fff, 0 0 1px #fff, 0 1px 3px rgba(0, 0, 0, .5); }

/* counters */
.tp--counter .tp__body { gap: .2rem; padding: 0 .25rem; color: #1b1a18; background: #f6f3eb; border-radius: 10px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .45); }
.tp__tally { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.tp__tally small { max-width: 100%; font-size: 11px; color: #5d584e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp__tally b { font-size: 24px; font-variant-numeric: tabular-nums; }
.tp__step { flex: none; width: 30px; height: 30px; padding: 0; font: 700 18px/1 system-ui, sans-serif; color: #1b1a18; background: #e4dfd2; border: 0; border-radius: 50%; cursor: pointer; }
.tp__step:hover { background: #d3cdbd; }

/* boards and mats */
.tp--board .tp__body { border-radius: 6px; box-shadow: 0 0 0 6px rgba(0, 0, 0, .28), 0 6px 18px rgba(0, 0, 0, .35); }
.tp--board.tp--felt .tp__body { border-radius: 26px; background-image: radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, .13), transparent 70%); box-shadow: 0 0 0 5px rgba(0, 0, 0, .3), inset 0 0 60px rgba(0, 0, 0, .28); }
.tp--board.tp--plain .tp__body { border-radius: 10px; }
.tp__title { position: absolute; left: 4px; bottom: calc(100% + 8px); font: 600 15px/1.2 system-ui, sans-serif; color: rgba(255, 255, 255, .88); text-shadow: 0 1px 2px rgba(0, 0, 0, .6); white-space: nowrap; pointer-events: none; }

/* notes */
.tp--note .tp__body { align-items: flex-start; justify-content: flex-start; padding: 10px 12px; font-size: 15px; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); border-radius: 2px 2px 14px 2px; }

@media (max-width: 900px) {
    .tt { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(22rem, 1fr) auto; }
    .tt__side { border-left: 0; border-top: 1px solid var(--rl-border); max-height: 11rem; }
    .tt__drop { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .tp.is-glide, .tt__hcard { transition: none; }
    .tp--die.is-rolling .tp__body, .tp--card.is-rolling .tp__body { animation: none; }
}
