/* =========================================================================
   gameManager/MTG/diceRoll.css — ★2026-09-05 THE OPENING ROLL
   (mechanics/diceRoll.js creates every element styled here; index.php has
   no markup for any of it). Fully self-scoped: #rollDiceBtn,
   #diceRollOverlay, #rollWinOverlay, .roll-die, .roll-label,
   .roll-win-dialog and body.roll-phase.

   z-order: the Roll Dice button and the parked dice sit at 7 (with the
   turn controls — above the hand strips (2–4) and the life dice (6), below
   the deck viewer / floating cards at 1000); a die in flight is 1600 (a
   throw happens on an empty table — nothing else is that high then); the
   presentation overlay is 9620 (above the card presentation's 9600, below
   the turn splash 9640 and the dice popup 9700) and the presented die +
   its label ride just above it; the winner dialog is 9630.
   ========================================================================= */

/* ---------- the button — beside the life die, in the hand strip ---------- */
#rollDiceBtn {
    position: fixed;
    bottom: calc(7.5vh - 20px);
    /* left is set by diceRoll.js from window.gameW(); the translate makes
       the RIGHT edge the anchor, so it always ends 74px left of centre */
    transform: translateX(-100%) translateY(6px) scale(0.96);
    z-index: 7;
    height: 40px;
    padding: 0 26px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffdc8e 0%, #f0b84a 100%);
    color: #2a1d05;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(240, 184, 74, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.18s ease, background-color 0.18s ease;
}

#rollDiceBtn.roll-dice-btn-in {
    opacity: 1;
    transform: translateX(-100%) translateY(0) scale(1);
}

#rollDiceBtn:hover {
    background: linear-gradient(180deg, #ffe4a3 0%, #f5c25c 100%);
    box-shadow: 0 8px 22px rgba(240, 184, 74, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
}

#rollDiceBtn:active {
    transform: translateX(-100%) translateY(1px) scale(0.97);
}

#rollDiceBtn.hidden {
    display: none;
}

/* Before the order is decided there is nothing to draw and nothing to
   view — the deck pile stays as scenery, its two buttons do not paint.
   (The server refuses the actions anyway; this just keeps the strip
   honest: one thing in the hand area, the Roll Dice button.) */
body.roll-phase #drawCardArea .drawACard,
body.roll-phase #drawCardArea .viewDeck {
    display: none !important;
}

/* ---------- the die — in flight, presented, parked ---------- */
.roll-die {
    position: fixed;
    z-index: 1600;
    pointer-events: none;
    transform-origin: center center;
    will-change: transform, left, top;
}

.roll-die.roll-die-present {
    z-index: 9621;
    /* a soft glow under the presented die, like the spotlit card */
    filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.55));
}

.roll-die.roll-rest {
    z-index: 7;
    transition: left 0.35s ease, top 0.35s ease, opacity 0.4s ease, transform 0.4s ease;
}

.roll-die.roll-rest-out {
    opacity: 0;
    transform: scale(0.6) !important;
}

/* =========================================================================
   ★2026-09-07 — THE 3D d20
   diceRoll.js's buildD20() writes:

     <div class="roll-die roll-d20 die-c-<color> d20-t-<texture>"
          style="font-size:<die px>">
       <div class="d20-scene">                       perspective
         <div class="d20">                           the rotating body
           <div class="d20-face d20-t-<texture>"      × 20
                style="clip-path:polygon(3 vertices); transform:matrix3d(u,v,n,c)">
             <div class="d20-shade"></div><span class="d20-num">7</span>

   THE TWO SIZES. The geometry is authored once at 100px (D20_BASE) and the
   BODY is scaled by the same matrix that rotates it, so a die is resized by
   font-size alone — which is what lets the presentation's fly() grow it.
   `.d20` therefore pins font-size:100px so the em-based texture gradients
   copied from dice.css below resolve against the AUTHORED size, not the
   painted one; the root's own font-size is left to drive the perspective.

   THE COLOUR comes from dice.css: `.die-c-*` sets --die-base/-hi/-lo/-ink/
   -ink-shadow and nothing else, so putting that class on the root is free.
   The `.die-t-*` classes are NOT reused — they paint a square die body and
   would show through the polyhedron — so the textures are re-cut here as
   `.d20-t-*` overlays on each face.
   ========================================================================= */
.roll-die.roll-d20 {
    width: 1em;
    height: 1em;
}

.roll-d20 .d20-scene {
    position: absolute;
    inset: 0;
    perspective: 4em;
    perspective-origin: 50% 50%;
}

.roll-d20 .d20 {
    position: absolute;
    inset: 0;
    font-size: 100px;          /* the authored size — see above */
    transform-style: preserve-3d;
    will-change: transform;
}

.d20-face {
    position: absolute;
    left: 50%;
    top: 50%;
    transform-origin: 50% 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: linear-gradient(160deg, var(--die-hi) 0%, var(--die-base) 45%, var(--die-lo) 100%);
}

/* the per-face lighting: diceRoll.js sets this opacity every frame from the
   face's world normal · the key light (0 facing the light → 0.55 away) */
.d20-shade {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #000;
    opacity: 0;
    pointer-events: none;
}

/* the texture overlay — the same gradients dice.css paints on .die::before */
.d20-face::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

/* the numeral — dice.css's lining-figure serif, in the ink colour */
.d20-num {
    position: relative;
    z-index: 3;
    font-family: "Times New Roman", "Palatino Linotype", Georgia, serif;
    font-variant-numeric: lining-nums;
    font-weight: 700;
    line-height: 1;
    color: var(--die-ink);
    text-shadow:
        0 0 0.06em var(--die-ink-shadow),
        0 0.02em 0.02em var(--die-ink-shadow),
        0 0 0.14em var(--die-ink-shadow);
    -webkit-user-select: none;
    user-select: none;
}

/* ---------- textures (cut from dice.css's .die-t-*::before) ---------- */
.d20-face.d20-t-glass::after {
    background:
        linear-gradient(118deg, rgba(255,255,255,0) 34%, rgba(255,255,255,0.32) 42%, rgba(255,255,255,0.55) 47%, rgba(255,255,255,0.10) 54%, rgba(255,255,255,0) 60%),
        linear-gradient(180deg, rgba(255,255,255,0) 70%, rgba(255,255,255,0.18) 100%);
    opacity: 0.9;
}

.d20-face.d20-t-stone::after {
    background-image:
        radial-gradient(circle at 78% 30%, rgba(0,0,0,0.25) 0 6%, rgba(0,0,0,0) 8%),
        radial-gradient(circle at 22% 72%, rgba(255,255,255,0.16) 0 5%, rgba(255,255,255,0) 8%),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.9 0'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
    background-size: 100% 100%, 100% 100%, 0.55em 0.55em;
    opacity: 0.5;
    mix-blend-mode: multiply;
}

.d20-face.d20-t-steel::after {
    background:
        repeating-linear-gradient(104deg, rgba(255,255,255,0.14) 0 0.02em, rgba(0,0,0,0.10) 0.02em 0.04em, rgba(255,255,255,0) 0.04em 0.075em);
    opacity: 0.85;
}

.d20-face.d20-t-wood::after {
    background-image:
        repeating-linear-gradient(4deg, rgba(60,30,5,0.16) 0 0.025em, rgba(60,30,5,0) 0.025em 0.12em, rgba(60,30,5,0.08) 0.12em 0.15em, rgba(60,30,5,0) 0.15em 0.27em),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='w'><feTurbulence type='fractalNoise' baseFrequency='0.015 0.32' numOctaves='3' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.25  0 0 0 0 0.12  0 0 0 0 0  0 0 0 0.75 0'/></filter><rect width='160' height='160' filter='url(%23w)'/></svg>");
    background-size: 100% 100%, 1.6em 1.6em;
    opacity: 0.55;
    mix-blend-mode: multiply;
}

.d20-face.d20-t-rugged::after {
    background-image:
        repeating-linear-gradient(38deg, rgba(255,255,255,0.20) 0 0.02em, rgba(255,255,255,0) 0.02em 0.17em),
        repeating-linear-gradient(-54deg, rgba(0,0,0,0.30) 0 0.015em, rgba(0,0,0,0) 0.015em 0.23em),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='r'><feTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' seed='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0'/></filter><rect width='120' height='120' filter='url(%23r)'/></svg>");
    background-size: 100% 100%, 100% 100%, 0.7em 0.7em;
    opacity: 0.58;
    mix-blend-mode: multiply;
}

/* ---------- ★2026-09-07 my resting die is a button ---------- */
.roll-die.roll-rest-mine {
    pointer-events: auto;
    cursor: pointer;
}

.roll-die.roll-rest-mine:hover {
    filter: drop-shadow(0 0 6px rgba(255, 214, 130, 0.85));
}

/* A FREE roll's die is driven frame by frame on its way home — the resting
   die's transitions would fight the driver. (After .roll-rest: same
   specificity, later wins.) */
.roll-die.roll-free {
    transition: none;
}

/* ---------- the presentation ---------- */
#diceRollOverlay {
    position: fixed;
    inset: 0;
    z-index: 9620;
    pointer-events: none;
    /* the card presentation's own backdrop (cardPresent.js ensureOverlay) */
    background: radial-gradient(ellipse at center, rgba(8, 10, 18, 0.55) 0%, rgba(4, 5, 10, 0.82) 100%);
    opacity: 0;
    transition: opacity 0.22s ease;
}

#diceRollOverlay.roll-overlay-on {
    opacity: 1;
}

/* "Your Roll" / "<name>'s Roll" — the turn splash's gold-foil serif */
.roll-label {
    position: fixed;
    z-index: 9622;
    left: 50%;
    transform: translate(-50%, -100%) translateY(8px);
    pointer-events: none;
    white-space: nowrap;
    font-family: "Palatino Linotype", "Times New Roman", Georgia, serif;
    font-weight: 700;
    font-size: clamp(26px, 4.2vw, 54px);
    letter-spacing: 0.06em;
    line-height: 1;
    background: linear-gradient(172deg,
        #fff6d8 0%, #ffe9a8 22%, #f0b84a 45%, #b97f1e 58%, #ffdf96 78%, #fff3cc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-stroke: 1px rgba(80, 52, 8, 0.55);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 18px rgba(255, 210, 122, 0.5));
    opacity: 0;
    transition: opacity 0.26s ease, transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.roll-label.roll-label-in {
    opacity: 1;
    transform: translate(-50%, -100%) translateY(0);
}

/* ★2026-09-07 — the free roll's second line: "<title> · d20". Plain and
   small, tucked between the gold label and the die. */
.roll-label.roll-sub {
    z-index: 9622;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    color: #f3e2b6;
    -webkit-text-stroke: 0;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.85));
}

/* ---------- ★2026-09-07 "Start Game" — where the Mulligan button sits --- */
#startGameBtn {
    position: fixed;
    right: calc(var(--chat-push, 0px) + 12px);
    bottom: calc(15vh + 10px);
    transform: translateY(6px) scale(0.96);
    z-index: 7;
    height: 40px;
    padding: 0 26px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffdc8e 0%, #f0b84a 100%);
    color: #2a1d05;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(240, 184, 74, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.18s ease, background-color 0.18s ease;
}

#startGameBtn.roll-dice-btn-in {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#startGameBtn:hover {
    background: linear-gradient(180deg, #ffe4a3 0%, #f5c25c 100%);
    box-shadow: 0 8px 22px rgba(240, 184, 74, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
}

#startGameBtn:active {
    transform: translateY(1px) scale(0.97);
}

#startGameBtn.hidden {
    display: none;
}

/* ---------- ★2026-09-07 the two consent dialogs ---------- */
#rollAgainOverlay,
#startGameOverlay {
    z-index: 9630;   /* the winner dialog's plane — only one is ever open */
}

.roll-vote-dialog .roll-vote-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.roll-vote-dialog .roll-vote-actions .dialog-button {
    flex: 0 1 auto;
}

/* ---------- "You won!" / "Your call" ---------- */
#rollWinOverlay {
    z-index: 9630;   /* above the presentation overlay, below the dice popup */
}

.roll-win-dialog {
    width: 400px;
    text-align: center;
}

.roll-win-dialog .instruction-text {
    margin: 8px 0 4px;
    color: #475569;
    font-size: 14px;
}

.roll-win-dialog .deck-actions {
    display: flex;
    align-items: center;
    margin-top: 18px;
}

.roll-win-dialog .spacer {
    flex: 1;
}

@media (prefers-reduced-motion: reduce) {
    #rollDiceBtn, .roll-die.roll-rest, #diceRollOverlay, .roll-label { transition: none; }
    /* ★2026-09-07 */
    #startGameBtn, .roll-die.roll-rest-mine { transition: none; }
    .roll-die.roll-rest-mine:hover { filter: none; }
}
