/* ============================================================
   PVZH VAULT — OPEN DECK SHEET
   Loaded after style.css and home.css. Selectors start with
   "html body .pvz-sheet" so they win over the stacked !important
   rules in style.css without editing that file.

   Layout
   - Wide (961px+):  cards on the left, a 232px rail on the right
                     (rating + sparks, star, analyze / copy link).
   - Medium (≤960):  the rail becomes one row above the cards.
   - Small  (≤640):  the rail stacks into full-width rows.
   ============================================================ */

html body .pvz-sheet {
    --ds-panel: rgba(8, 10, 14, 0.34);
    --ds-line: rgba(255, 255, 255, 0.1);
    --ds-line-strong: rgba(255, 255, 255, 0.2);
    --ds-text: #eef3f5;
    --ds-muted: #a0aab2;
    --ds-gold: #ffd34e;
    --ds-accent: #00b4d8;
    --ds-spark: #4dd0e1;
}

/* ---------- Body layout ---------- */

html body .pvz-sheet .pvz-sheet-body {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 232px !important;
    align-items: start !important;
    column-gap: 28px !important;
    row-gap: 0 !important;
    padding: 24px 28px 28px !important;
}

html body .pvz-sheet .pvz-card-grid {
    grid-column: 1 !important;
    grid-row: 1 !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 12px 10px !important;
    width: 100% !important;
    max-width: none !important;
    justify-content: stretch !important;
}

html body .pvz-sheet .pvz-card img {
    max-height: 124px !important;
}

html body .pvz-sheet .pvz-deck-history {
    grid-row: 2 !important;
}


/* ---------- Rail ---------- */

html body .pvz-sheet .pvz-sheet-rail {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

/* Rating + sparks: one panel, two rows */
html body .pvz-sheet .pvz-sheet-stats {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 2px 14px;
    border: 1px solid var(--ds-line);
    border-radius: 10px;
    background: var(--ds-panel);
}

html body .pvz-sheet .pvz-sheet-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 50px;
}

html body .pvz-sheet .pvz-sheet-stat + .pvz-sheet-stat {
    border-top: 1px solid var(--ds-line);
}

html body .pvz-sheet .pvz-sheet-stat dt {
    margin: 0;
    color: var(--ds-muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

html body .pvz-sheet .pvz-sheet-stat dd {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--ds-text);
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* Same treatment as the grade square on the homepage */
html body .pvz-sheet .pvz-sheet-grade {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(14, 18, 21, 0.72);
    color: var(--pvz-grade, #ffffff);
    font-size: 18px;
    font-weight: 700;
}

/* Same sparkle as the mobile feed */
html body .pvz-sheet .pvz-sheet-sparks svg {
    flex: none;
    width: 16px;
    height: 16px;
    fill: var(--ds-spark);
}


/* ---------- Star ---------- */

html body .pvz-sheet .deck-star-btn.pvz-sheet-star {
    position: static;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 0 16px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 211, 78, 0.38);
    border-radius: 10px;
    background: rgba(255, 211, 78, 0.07);
    color: var(--ds-text);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    text-align: left;
    cursor: pointer;
    transform: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

html body .pvz-sheet .deck-star-btn.pvz-sheet-star:hover {
    border-color: rgba(255, 211, 78, 0.65);
    background: rgba(255, 211, 78, 0.13);
}

html body .pvz-sheet .deck-star-btn.pvz-sheet-star:focus-visible {
    outline: 2px solid var(--ds-accent);
    outline-offset: 2px;
}

html body .pvz-sheet .deck-star-btn.pvz-sheet-star:disabled {
    cursor: progress;
    opacity: 0.75;
}

html body .pvz-sheet .deck-star-btn.pvz-sheet-star svg {
    flex: none;
    width: 22px;
    height: 22px;
    fill: transparent;
    stroke: var(--ds-gold);
    stroke-width: 1.8px;
    stroke-linejoin: round;
    animation: none;
    transition: fill 0.15s ease;
}

html body .pvz-sheet .pvz-sheet-star .pvz-sheet-star-word .is-on,
html body .pvz-sheet .pvz-sheet-star.starred .pvz-sheet-star-word .is-off {
    display: none;
}

html body .pvz-sheet .pvz-sheet-star.starred .pvz-sheet-star-word .is-on {
    display: inline;
}

html body .pvz-sheet .deck-star-btn.pvz-sheet-star .deck-star-count {
    position: static;
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ds-muted);
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

html body .pvz-sheet .deck-star-btn.pvz-sheet-star .deck-star-count[hidden] {
    display: none;
}

/* Starred: the gold moves inside, the count turns gold */
html body .pvz-sheet .deck-star-btn.pvz-sheet-star.starred {
    border-color: rgba(255, 211, 78, 0.7);
    background: rgba(255, 211, 78, 0.18);
    color: var(--ds-gold);
}

html body .pvz-sheet .deck-star-btn.pvz-sheet-star.starred svg {
    fill: var(--ds-gold);
}

html body .pvz-sheet .deck-star-btn.pvz-sheet-star.starred .deck-star-count {
    color: var(--ds-gold);
}

html body .pvz-sheet .deck-star-btn.pvz-sheet-star.is-popping svg {
    animation: pvzSheetStarPop 0.42s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes pvzSheetStarPop {
    0% { transform: scale(1); }
    45% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* 50-star milestone: two overlapping stars, as on the homepage */
html body .pvz-sheet .pvz-sheet-star .pvz-star-stack {
    position: relative;
    display: block;
    flex: none;
    line-height: 0;
    margin-left: 7px;
}

html body .pvz-sheet .pvz-sheet-star .pvz-star-stack > svg {
    position: relative;
    z-index: 1;
}

html body .pvz-sheet .pvz-sheet-star .pvz-star-stack > svg.pvz-star-twin {
    position: absolute;
    z-index: 0;
    left: -42%;
    top: -14%;
    transform: scale(0.82);
    opacity: 0.7;
}


/* ---------- Analyze / Copy link ---------- */

html body .pvz-sheet .pvz-sheet-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

html body .pvz-sheet .pvz-sheet-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 0;
    min-height: 40px;
    margin: 0;
    padding: 0 10px;
    box-sizing: border-box;
    border: 1px solid var(--ds-line);
    border-radius: 10px;
    background: transparent;
    color: var(--ds-text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

html body .pvz-sheet .pvz-sheet-action svg {
    flex: none;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

html body .pvz-sheet .pvz-sheet-action:hover {
    border-color: var(--ds-line-strong);
    background: rgba(255, 255, 255, 0.06);
}

html body .pvz-sheet .pvz-sheet-action:focus-visible {
    outline: 2px solid var(--ds-accent);
    outline-offset: 2px;
}

html body .pvz-sheet .pvz-sheet-action:disabled {
    cursor: default;
    opacity: 1;
}

html body .pvz-sheet .pvz-sheet-action.is-done {
    border-color: rgba(0, 180, 216, 0.55);
    color: var(--ds-accent);
}


/* ---------- Medium: rail becomes one row above the cards ---------- */

@media (max-width: 960px) {
    html body .pvz-sheet .pvz-sheet-body {
        grid-template-columns: minmax(0, 1fr) !important;
        row-gap: 20px !important;
        padding: 20px 22px 24px !important;
    }

    html body .pvz-sheet .pvz-sheet-rail {
        grid-column: 1;
        grid-row: 1;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
    }

    html body .pvz-sheet .pvz-card-grid {
        grid-row: 2 !important;
        grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)) !important;
    }

    html body .pvz-sheet .pvz-deck-history {
        grid-row: 3 !important;
        margin-top: 4px !important;
    }

    html body .pvz-sheet .pvz-sheet-stats {
        flex: none;
        flex-direction: row;
        align-items: center;
        padding: 0 14px;
    }

    html body .pvz-sheet .pvz-sheet-stat {
        min-height: 46px;
        justify-content: flex-start;
        gap: 10px;
    }

    html body .pvz-sheet .pvz-sheet-stat + .pvz-sheet-stat {
        margin-left: 14px;
        padding-left: 14px;
        border-top: 0;
        border-left: 1px solid var(--ds-line);
    }

    html body .pvz-sheet .deck-star-btn.pvz-sheet-star {
        flex: 1 1 150px;
        width: auto;
        min-height: 48px;
    }

    html body .pvz-sheet .pvz-sheet-actions {
        flex: none;
        grid-template-columns: auto auto;
    }

    html body .pvz-sheet .pvz-sheet-action {
        min-height: 48px;
        padding: 0 14px;
    }
}


/* ---------- Small: full-width rows (Fun Facts opens the sheet on phones) ---------- */

@media (max-width: 640px) {
    html body .pvz-sheet .pvz-sheet-body {
        padding: 16px 16px 20px !important;
    }

    html body .pvz-sheet .pvz-sheet-rail {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    html body .pvz-sheet .pvz-sheet-stats {
        justify-content: space-between;
    }

    html body .pvz-sheet .pvz-sheet-stat {
        flex: 1 1 0;
        justify-content: space-between;
    }

    html body .pvz-sheet .pvz-sheet-actions {
        grid-template-columns: 1fr 1fr;
    }

    html body .pvz-sheet .pvz-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)) !important;
    }
}


@media (prefers-reduced-motion: reduce) {
    html body .pvz-sheet .deck-star-btn.pvz-sheet-star.is-popping svg {
        animation: none;
    }
}
