/*
Joker page: intro text and the three joker cards, plus the wheel.
Layout ranges: phone up to 600px, tablet 601-950px (one column), desktop from 951px (two columns).
*/

/* Frame: 32px side margins, at most 1200px wide, content starts 64px below the 80px header (48px on phones) */
main {
    box-sizing: border-box;
    width: min(calc(100% - 64px), 1200px);
    margin: calc(5rem + 64px) auto 0;
}

.joker-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: 4rem;
}

.joker-details {
    min-width: 0;
}

.joker-intro {
    max-width: 680px;
    margin: 0 auto;
    text-align: center;
}


/* Body text, same as the legal and rules pages */
.joker-intro p {
    margin: 0;
    font-size: 1.0625rem;
    line-height: 1.5;
}

.cards {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 1.25rem;
    margin: 4rem 0 0;
}

.joker {
    flex: 1;
    max-width: 180px;
    min-width: 0;
    text-align: center;
    /* Lets the weak-spot badge size itself from the card width (cqi = 1% of the card width) */
    container-type: inline-size;
}

.card {
    display: block;
    width: 100%;
    aspect-ratio: 833 / 1158;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transition: transform .5s, rotate .5s;
}

.card-inner {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
}

.card-back, .card-front {
    position: absolute;
    inset: 0;
    border-radius: 5%;
    box-shadow: 0 14px 30px #0008;
    overflow: hidden;
}

/* One face at a time: the back, or the front once joker.js has turned the card ("show-front").
   The turn itself is a flat squeeze (joker.js), not a 3D rotation: browsers draw 3D elements as a stretched
   picture, which looked blurry on desktop screens (Firefox with display scaling) and jumped back to sharp. */
.card-front, .joker.show-front .card-back {
    visibility: hidden;
}

.joker.show-front .card-front {
    visibility: visible;
}

.card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: white;
}

.joker:nth-child(1) .card {
    rotate: -5deg;
}

.joker:nth-child(3) .card {
    rotate: 5deg;
}

/* The outer cards are tilted 5deg, so their highest corner sits 4.1% of the card width above their top edge.
   The middle card (and its badge) is raised by the same amount, so all three tops line up. */
.joker:nth-child(2) .card, .joker:nth-child(2) .joker-info {
    translate: 0 -4.1cqi;
}

/* Hover lift only with a mouse or trackpad: on touch screens a tap leaves the card in hover state */
@media (hover: hover) and (pointer: fine) {
    .card:hover {
        transform: translateY(-8px);
    }
}

.card:focus-visible {
    outline: 2px solid white;
    outline-offset: 8px;
    border-radius: 5%;
}

.joker.is-open .card {
    transform: scale(1.12);
    rotate: 0deg;
    position: relative;
    z-index: 1;
}



/* Weak-spot badge: a stamp overlapping the bottom edge of the flipped card, so little room is reserved for it */
.joker-info {
    position: relative;
    z-index: 2;
    margin-top: -14cqi;
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transition: opacity .3s, transform .5s cubic-bezier(.2, .8, .3, 1.25), visibility .3s;
}

.joker-info[hidden] {
    display: block;
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(.8);
}

.joker-info:not([hidden]) {
    transition-delay: .2s;
}

/* Everything in cqi: the badge keeps the same size relative to its card on every screen
   (on a 176px desktop card: 63px wide, 5px padding, 3px border, as before) */
.weakness-badge {
    position: relative;
    width: 36cqi;
    margin: 0 auto;
    padding: 2.8cqi;
    border: 1.7cqi solid white;
    border-radius: 50%;
    background: black;
    box-shadow: 0 2.8cqi 0 black, 0 5.7cqi 11.4cqi #0007;
    transform: rotate(-8deg);
}

.weakness-badge::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 16%;
    width: 68%;
    height: 2.3cqi;
    border-radius: 1.2cqi;
    background: white;
    box-shadow: 0 0 0 1.1cqi black;
    transform: rotate(-40deg);
}

.weakness-icon {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 50%;
}

.joker-wheel-section {
    width: 100%;
    min-width: 0;
    margin: 0;
    /* Room for the pointer, which sticks out 20px above the wheel */
    padding-top: 1.25rem;
    text-align: center;
}

/* The wheel is drawn at its real size (no scaling) */
.joker-wheel-frame {
    position: relative;
    width: min(100%, 440px);
    margin: 0 auto;
}

.joker-wheel {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.joker-wheel:focus-visible {
    outline: 2px solid white;
    outline-offset: 9px;
}

.joker-wheel[aria-disabled="true"] {
    cursor: wait;
}

.joker-wheel-disc {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.wheel-sector-highlight {
    opacity: 0;
    fill: white;
    fill-opacity: .35;
    stroke: white;
    stroke-width: 8px;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 9px white);
    pointer-events: none;
}

.joker-wheel-hub {
    position: absolute;
    inset: 40%;
    display: grid;
    place-items: center;
    padding: 5px;
    pointer-events: none;
}

.joker-wheel-hub img {
    display: block;
    width: 100%;
    height: auto;
}

.joker-wheel-pointer {
    position: absolute;
    z-index: 1;
    top: -1.25rem;
    left: 50%;
    width: 40px;
    height: auto;
    transform: translateX(-50%);
    pointer-events: none;
}

.wheel-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Tablet: one column (text and cards, then the wheel) */
@media (max-width: 950px) {
    .joker-layout {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        gap: 4rem;
    }

    .joker-details {
        width: min(100%, 680px);
    }

    .joker {
        max-width: 200px;
    }
}

/* Phone: three cards side by side across the full width */
@media (max-width: 600px) {
    main {
        margin-top: calc(5rem + 48px);
    }

    .joker-layout {
        gap: 3rem;
    }

    .cards {
        gap: .75rem;
        margin-top: 3rem;
    }

    .joker {
        max-width: none;
    }

    .joker-wheel-frame {
        width: min(100%, 400px);
    }

    .joker-wheel-pointer {
        width: 32px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .card, .card-inner, .joker-info {
        transition: none;
    }
}
