/* ==========================================================
   HORROR SOLITAIRE - the cards themselves

   Every face is drawn here: corners, pip grids, court cards
   and the back. No image files, so nothing 404s, nothing has
   to download, and a card stays sharp at any size.
   ========================================================== */

.card {
    position: absolute;
    top: 0;
    left: 0;

    width: var(--card-width);
    height: var(--card-height);

    border-radius: var(--card-radius);
    border: 1px solid var(--card-edge);

    /* Belt and braces: nothing drawn on a card may escape it. */
    overflow: hidden;

    background:
        linear-gradient(150deg, #fbf7ee 0%, var(--card-face) 45%, #ddd4c1 100%);

    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.5),
        0 6px 14px rgba(0, 0, 0, 0.45);

    cursor: grab;

    /* Aged paper speckle. */
    background-blend-mode: normal;
}

.card::before {
    content: "";

    position: absolute;
    inset: 0;

    border-radius: inherit;
    pointer-events: none;

    background-image:
        radial-gradient(circle, rgba(60, 40, 20, 0.08) 0.5px, transparent 0.5px);
    background-size: 4px 4px;

    opacity: 0.55;
}


/* ----------------------------------------------------------
   Position within a pile
   ---------------------------------------------------------- */

.tableau-pile .card {
    transform: translateY(calc(var(--stack, 0) * var(--stack-step)));
}

.waste .card {
    transform: translateX(calc(var(--fan, 0) * var(--card-width) * 0.28));
}

/* Only the top waste card can be picked up. */
.card.buried {
    pointer-events: none;
    filter: brightness(0.82);
}

.card.stub {
    pointer-events: none;
}


/* ----------------------------------------------------------
   Colour
   ---------------------------------------------------------- */

.card.red {
    color: #9c1218;
}

.card.black {
    color: #17140f;
}


/* ----------------------------------------------------------
   Corner index
   ---------------------------------------------------------- */

.corner {
    position: absolute;

    display: flex;
    flex-direction: column;
    align-items: center;

    line-height: 0.95;

    font-family: "Iowan Old Style", Georgia, serif;
    font-weight: bold;
}

.corner.tl {
    top: calc(var(--card-width) * 0.055);
    left: calc(var(--card-width) * 0.06);
}

.corner.br {
    right: calc(var(--card-width) * 0.06);
    bottom: calc(var(--card-width) * 0.055);
    transform: rotate(180deg);
}

.corner-rank {
    font-size: calc(var(--card-width) * 0.24);
    letter-spacing: -0.03em;
}

.corner-suit {
    font-size: calc(var(--card-width) * 0.19);
    margin-top: calc(var(--card-width) * 0.01);
}


/* ----------------------------------------------------------
   Pip grid - the middle of a numbered card
   ---------------------------------------------------------- */

.pips {
    position: absolute;
    inset:
        calc(var(--card-height) * 0.09)
        calc(var(--card-width) * 0.26);

    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(7, 1fr);

    pointer-events: none;
}

.pip {
    display: flex;
    align-items: center;
    justify-content: center;

    /* Sized from the card's HEIGHT, because the seven grid rows are
       too. Sizing this from the width instead is what pushed pips
       out through the bottom edge on a phone. */
    font-size: calc(var(--card-height) * 0.135);
    line-height: 0.8;
}

/* The lower half of a real card has its pips upside down. */
.pip.flipped {
    transform: rotate(180deg);
}


/* ----------------------------------------------------------
   Court cards
   ---------------------------------------------------------- */

.court {
    position: absolute;
    inset:
        calc(var(--card-height) * 0.13)
        calc(var(--card-width) * 0.17);

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    border: 1px solid currentColor;
    border-radius: calc(var(--card-radius) * 0.7);

    opacity: 0.92;
    pointer-events: none;

    background:
        repeating-linear-gradient(
            45deg,
            rgba(0, 0, 0, 0.03) 0 3px,
            transparent 3px 6px
        );
}

.court-glyph {
    font-size: calc(var(--card-width) * 0.46);
    line-height: 1;
}

.court-suit {
    font-size: calc(var(--card-width) * 0.2);
    margin-top: calc(var(--card-width) * 0.05);
    opacity: 0.75;
}


/* ----------------------------------------------------------
   Card back
   ---------------------------------------------------------- */

.card.face-down {
    background:
        repeating-linear-gradient(
            45deg,
            rgba(255, 255, 255, 0.05) 0 4px,
            transparent 4px 9px
        ),
        radial-gradient(
            circle at 50% 42%,
            #5c1216 0%,
            #2a0a0c 55%,
            #150607 100%
        );

    border: 1px solid #0a0505;

    box-shadow:
        inset 0 0 0 calc(var(--card-width) * 0.03) #7d1c22,
        inset 0 0 0 calc(var(--card-width) * 0.04) #140708,
        0 1px 2px rgba(0, 0, 0, 0.6),
        0 6px 14px rgba(0, 0, 0, 0.5);

    color: #c8a06a;
}

.card.face-down::before {
    /* Replaces the paper speckle with the back's own emblem. */
    content: "☠";

    display: flex;
    align-items: center;
    justify-content: center;

    inset: calc(var(--card-width) * 0.09);

    border: 1px solid rgba(200, 160, 106, 0.35);
    border-radius: calc(var(--card-radius) * 0.6);

    background: none;

    font-size: calc(var(--card-width) * 0.42);
    text-shadow: 0 0 calc(var(--card-width) * 0.12) rgba(220, 60, 40, 0.5);

    opacity: 1;
}


/* ----------------------------------------------------------
   States
   ---------------------------------------------------------- */

.card.selected {
    box-shadow:
        0 0 0 2px #c9a45f,
        0 0 calc(var(--card-width) * 0.22) rgba(201, 164, 95, 0.55),
        0 8px 18px rgba(0, 0, 0, 0.6);
}

/* The card left behind while its copy is being dragged. */
.card.lifted {
    opacity: 0.28;
    filter: grayscale(0.5);
}


/* ----------------------------------------------------------
   Drag layer

   Lives on <body>, above everything, and takes no pointer
   events so the drop target underneath can be found.
   ---------------------------------------------------------- */

.drag-layer {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 500;

    pointer-events: none;

    will-change: transform;
}

.drag-layer .card {
    position: absolute;

    transform: translateY(calc(var(--stack, 0) * var(--stack-step)));

    box-shadow:
        0 calc(var(--card-width) * 0.1) calc(var(--card-width) * 0.3)
        rgba(0, 0, 0, 0.75);
}

.drag-layer .card.dragging {
    cursor: grabbing;
}
