/* ============================================
   SHARED COMPONENTS
   Reusable patterns consolidated for consistency
   ============================================ */

/* ============================================
   UNAVAILABLE BUTTON STATE
   Applied when a button exists but its action is
   currently blocked (empty deck, not signed in, not owner).
   The element stays clickable so it can show a feedback toast.
   ============================================ */
.btn-unavailable {
    opacity: 0.38;
    cursor: not-allowed !important;
}

.btn-unavailable:hover {
    filter: none !important;
    opacity: 0.38 !important;
    transform: none !important;
}

/* Synergy card preview */
.synergy-card-preview {
    position: fixed;
    right: calc(400px + 280px);
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--z-dropdown);
    pointer-events: none;
    animation: fadeIn 0.15s ease;
}

.synergy-card-preview img {
    width: 260px;
    border-radius: var(--radius-2xl);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
}

/* Deck list specific */
.deck-list-scrollable {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    height: auto;
    /* Respect siblings in flex column */
}

@media (max-width: 768px) {
    .scrollable-list,
    .deck-list-scrollable {
        overflow-y: visible;
        height: auto;
        flex: none;
    }
}

/* ============================================
   SYNERGY ITEM - Shared synergy display
   Used in Stats panel and Genome info panel
   ============================================ */
.synergy-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1-5) var(--space-2-5);
    background: var(--input-bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    border: 1px solid transparent;
}

.synergy-item:hover {
    background: var(--input-bg);
    border-color: var(--accent-color);
    transform: translateX(4px);
}

.synergy-item.expanded {
    background: var(--accent-bg);
    border-left: 3px solid var(--accent-color);
}

.synergy-item.clickable {
    cursor: pointer;
    user-select: none;
}

.synergy-item.clickable:hover {
    background: var(--input-bg);
    border-color: var(--accent-color);
}

.synergy-type-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-round);
    flex-shrink: 0;
    box-shadow: 0 0 4px currentColor;
}

.synergy-card-name {
    font-size: 0.8em;
    color: var(--text-color);
}

.synergy-details {
    margin-left: var(--space-6);
    padding: var(--space-2) 0;
    border-left: 2px solid var(--accent-bg-hover);
    margin-top: var(--space-1);
}

/* ============================================
   MANA SYMBOLS
   Shared mana symbol display
   ============================================ */
.mana-symbol {
    width: 16px;
    height: 16px;
}

/* ============================================
   LOADING STATES
   ============================================ */
.no-results {
    text-align: center;
    color: #666;
    padding: var(--space-10);
}

/* ============================================
   BADGE COMPONENTS
   ============================================ */
.badge {
    display: inline-block;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: 0.8em;
    font-weight: bold;
}

.badge.free {
    background: #e0e0e0;
    color: #333;
}

.badge.pro {
    background: gold;
    color: black;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* ============================================
   VIRTUAL LIST - Efficient windowed scrolling
   ============================================ */
.virtual-list {
    position: relative;
    overflow-y: auto;
    height: 100%;
}

.virtual-list-item {
    box-sizing: border-box;
    width: 100%;
}

/* ============================================
   STATUS INDICATORS
   ============================================ */
.status-indicator {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-0-5) var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.status-indicator:not(:empty) {
    display: inline-block;
}

.status-indicator[data-state="ready"] {
    color: var(--success-color);
    border-color: color-mix(in srgb, var(--success-color) 30%, transparent);
}

.status-indicator[data-state="processing"] {
    color: var(--warning-color);
    border-color: color-mix(in srgb, var(--warning-color) 30%, transparent);
}

/* ============================================
   ENTRY CHIP — shared keyword/glossary chip
   Used by GlossaryEntryCard for category badges
   and see-also links in both the card modal and
   the glossary panel.
   ============================================ */
button.entry-chip {
    padding: var(--space-0-5) var(--space-2-5);
    background: color-mix(in srgb, var(--text-color) 5%, transparent);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

button.entry-chip:hover {
    background: rgba(var(--accent-rgb), 0.1);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

button.entry-chip:active {
    transform: translateY(0);
}

.status-indicator[data-state="error"] {
    color: var(--danger-color);
    border-color: var(--danger-border);
}

/* ============================================
   PAGINATION NAVIGATION
   ============================================

   The Library's page controls (`components/pagination.rs`): one outlined
   group, `‹ Page 3 of 12 ›`. The readout opens a menu to type a page or pick
   one from the list. The readout is sized for the largest page count
   (`--page-digits`), so the group keeps one width and the arrows stay put as
   the pages turn. */

.pagination-nav {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Under a list, and over one: centred, with a rule between it and the decks. */
.pagination-nav--bottom {
    margin: var(--space-8) 0;
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-color);
}

.pagination-nav--top {
    margin: 0 0 var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.pagination-stepper {
    display: inline-flex;
    align-items: stretch;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    /* Not clipped: the jump menu hangs below the readout, inside this group.
       The end buttons round their own corners instead. */
}

.pagination-step:first-child {
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.pagination-step:last-child {
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.pagination-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.pagination-step:hover:not(:disabled) {
    background: var(--accent-bg);
    color: var(--accent-color);
}

.pagination-step:disabled {
    cursor: default;
    opacity: 0.35;
}

/* The readout: as wide as "Page 99 of 99" needs for this list's page count,
   with room for the current page's bold figures, so it never grows as the
   pages turn. */
.pagination-readout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-width: calc((12 + 2.4 * var(--page-digits, 1)) * 1ch);
    padding: 0 var(--space-2-5);
    border: 0;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    cursor: pointer;
}

.pagination-readout strong {
    color: var(--text-color);
    font-weight: 700;
}

.pagination-readout:hover,
.pagination-readout[aria-expanded="true"] {
    background: var(--accent-bg);
    color: var(--text-color);
}

.pagination-step:focus-visible,
.pagination-readout:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
}

/* The jump menu: a page number to type, then every page to pick from. */
.pagination-jump {
    min-width: 248px;
}

.pagination-jump-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2-5);
    padding: var(--space-1-5) var(--space-2) var(--space-2);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.pagination-jump-head > span {
    white-space: nowrap;
}

.pagination-jump-head .pagination-jump-input {
    width: 10ch;
    height: 28px;
    padding: 0 var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text-color);
    font: inherit;
    font-variant-numeric: tabular-nums;
}

.pagination-jump-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--space-1);
    max-height: 196px;
    padding: 0 var(--space-2) var(--space-2);
    overflow-y: auto;
}

.pagination-jump-page {
    height: 28px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.pagination-jump-page:hover:not(:disabled) {
    border-color: var(--border-color);
    color: var(--text-color);
}

.pagination-jump-page.active {
    background: var(--accent-gradient);
    color: var(--button-primary-text);
    font-weight: 700;
}

/* ── Reusable SortControl (field dropdown + asc/desc toggle) ──────────────── */
.sort-control {
    display: flex;
    align-items: center;
    gap: var(--space-1-5);
    width: 100%;
}

.sort-control-select {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-color);
    padding: 0 var(--space-2-5);
    font-size: 0.9em;
    cursor: pointer;
}

.sort-control-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}

/* Direction toggle reuses the .advanced-toggle-group / .toggle-btn pill style, sized to
   its short Asc/Desc labels rather than the wider Cost/Identity ones. */
.sort-direction-toggle {
    flex: 0 0 auto;
}

.sort-direction-toggle .toggle-btn {
    min-width: 40px;
    padding: var(--space-0-5) var(--space-2-5);
}

/* ============================================
   Shared hollow pie (donut) chart
   (DonutChart — Deckbuilder Stats + Collection)
   ============================================ */

.donut-chart-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    flex-wrap: wrap;
}

.donut-pie {
    width: 118px;
    height: 118px;
    flex: 0 0 118px;
    border-radius: var(--radius-round);
    -webkit-mask: radial-gradient(circle at center, transparent 45%, #000 46%);
    mask: radial-gradient(circle at center, transparent 45%, #000 46%);
}

.donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1-5);
    min-width: 120px;
}

.donut-legend li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 12px;
    color: var(--text-muted);
}

.donut-swatch {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-sm);
    flex: 0 0 10px;
}

.donut-key {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 3px;
    overflow: hidden;
}

.donut-legend b {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
/* Combo outcomes sit below the piece images now: the reader identifies the
   combo from its cards first, and "what it does" answers that rather than
   heading it. Grouped and labeled so the tags read as a set of results rather
   than loose metadata floating above the widget. */
.combo-outcomes {
    margin: var(--space-3) 0;
    padding: var(--space-2-5) var(--space-3);
    border: 1px solid color-mix(in srgb, var(--accent-color) 30%, var(--border-color));
    border-radius: var(--radius-xl);
    background: color-mix(in srgb, var(--accent-color) 5%, var(--card-bg));
}

.combo-outcomes-title {
    margin-bottom: 7px;
    color: var(--accent-color);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Outcomes read as a list, not a row of badges.

   Badges suited one- or two-word tags, but an outcome is a short sentence
   ("Infinite colorless mana", "Each opponent loses the game"). Wrapped into
   pills they broke mid-phrase and looked like metadata rather than the result
   the combo produces. */
.combo-outcomes-list {
    margin: 0;
    padding-left: 1.1rem;
    list-style: disc;
}

.combo-outcomes-list li {
    margin: 0 0 var(--space-1) 0;
    line-height: 1.45;
}

.combo-outcomes-list li:last-child {
    margin-bottom: 0;
}

/* Outcomes beside the walkthrough when the panel is wide enough.

   They answer different questions — "what do I get" and "how do I get it" — and
   stacking them pushed the steps below the fold on a desktop panel that had
   room to spare. The walkthrough gets the larger share because its lines are
   longer. Single column by default so the narrow case needs no override; the
   breakpoint is on the panel's own width, not the viewport's, because this
   widget also renders inside a half-width Explore column. */
.combo-details-host {
    container-type: inline-size;
    container-name: combo-details-host;
}

.combo-details {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
    align-items: start;
}

@container combo-details-host (min-width: 860px) {
    .combo-details {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
    }
}

/* Fallback for browsers without container queries: use the viewport instead.
   Slightly conservative so a wide viewport with a narrow panel does not get a
   cramped two-column split. */
@supports not (container-type: inline-size) {
    @media (min-width: 1400px) {
        .combo-details {
            grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
        }
    }
}

.combo-walkthrough {
    min-width: 0;
}

/* The outcomes box already carries a border; the walkthrough sits beside it as
   plain content, so it gets matching vertical rhythm without a second frame. */
.combo-details .combo-outcomes {
    margin: 0;
}

.combo-details .combo-steps {
    margin-top: var(--space-1-5);
}

/* Step 0 is the assumed board state. Keep it outside the action counter so the
   first actual combo action remains step 1; its requirements are lettered A/B/C. */
.combo-steps > li.combo-prerequisite-step {
    align-items: flex-start;
    counter-increment: none;
}

.combo-steps > li.combo-prerequisite-step::before {
    content: "0";
}

.combo-prerequisite-card {
    position: relative;
    flex: 1;
    min-width: 0;
    padding: var(--space-2) var(--space-2-5);
    margin-bottom: var(--space-2);
    border-left: 3px solid var(--accent-color);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: color-mix(in srgb, var(--accent-color) 6%, transparent);
}

.combo-prerequisite-label {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--accent-color);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

/* Commander Spellbook's notes, after the steps: what they assume. */
.combo-notes {
    margin-top: var(--space-2-5);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-color);
}

.combo-notes-label {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.combo-notes-text {
    margin: 0 0 var(--space-1);
    font-size: 0.8em;
    line-height: 1.5;
    color: var(--text-secondary);
}

.combo-prerequisite-substeps {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: combo-prerequisite;
}

.combo-prerequisite-substeps > li {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    min-height: 22px;
    counter-increment: combo-prerequisite;
}

.combo-prerequisite-substeps > li::before {
    content: counter(combo-prerequisite, upper-alpha);
    position: relative;
    z-index: 1;
    display: inline-flex;
    flex: 0 0 22px;
    align-items: center;
    justify-content: center;
    height: 22px;
    border: 1px solid color-mix(in srgb, var(--accent-color) 70%, white);
    border-radius: var(--radius-round);
    background: var(--widget-bg);
    color: var(--accent-color);
    font-size: 0.72rem;
    font-weight: 800;
}

/* Canonical user-authored text control shared by the main and admin apps. */
.standard-text-field {
    /* Anchor for the counter, which sits inside the input's box. */
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.image-picker-search-field,
.share-url-field,
.settings-email-field,
.billing-referral-link-field {
    flex: 1 1 auto;
}

.standard-text-field > input,
.standard-text-field > textarea {
    box-sizing: border-box;
    max-width: 100%;
}

/* The field draws its own clear button beside the counter, so a `type="search"` input's
   native one would be a second X. */
.standard-text-field > input[type="search"]::-webkit-search-cancel-button,
.standard-text-field > input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

/* Counter + clear affordance, overlaid inside the input's box rather than on a line of its
   own below. The line below is what caused the trouble historically: every counted field was
   one counter taller than the controls beside it, and half a dozen layouts grew compensation
   rules to re-align rows that had stopped lining up. Inside the box it occupies no layout
   space at all.

   The affix only materializes while the field is focused AND holds text (`.stf-active`, set
   by the widget): empty fields don't advertise "0/500", and blurring fades everything out so
   only the user's text remains. While inactive it is fully click-through. The accent
   gradient behind it signals "metadata about this field's text", and the active-state
   padding rule further down reserves the affix's footprint so the field's text scrolls left
   rather than rendering underneath it. */
.standard-text-field-affix {
    position: absolute;
    top: 1px;
    bottom: 1px;
    right: 1px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 7px 0 22px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(var(--accent-rgb), 0.14) 35%,
        rgba(var(--accent-rgb), 0.32)
    );
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.standard-text-field.stf-active > .standard-text-field-affix {
    opacity: 1;
}

/* On textareas the affix hugs the last line instead of stretching the field's full height. */
.standard-text-field.stf-multiline > .standard-text-field-affix {
    top: auto;
    height: 1.5rem;
}

.standard-text-field-count {
    margin: 0;
    color: var(--text-color);
    font-size: 0.6rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    opacity: 0.9;
    pointer-events: none;
}

.standard-text-field-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-color);
    cursor: pointer;
    /* Inherits click-through from the faded affix; re-enabled only while active. */
    pointer-events: none;
}

.standard-text-field.stf-active > .standard-text-field-affix > .standard-text-field-clear {
    pointer-events: auto;
}

.standard-text-field-clear:hover {
    background: rgba(var(--accent-rgb), 0.35);
}

/* The affix's footprint (keyed off `--stf-count-chars`, the worst-case counter width) is
   reserved by the widget as an *inline* style while active — consumer CSS routinely sets
   the `padding` shorthand on these controls at cascade positions that beat any rule this
   sheet could ship, and inline always wins. */
.card-autocomplete-input-row {
    /* The counter lives inside the field's box and adds no height below it. */
    position: relative;
    display: flex;
    align-items: flex-start;
}

/* The autocomplete's bespoke clear button and explicit Search button are both gone:
   StandardTextField ships the count + clear affix, and Enter submits the query. */

/* Shared deck-card artwork behavior used by Home, Library, Favorites, and Discover. */
.deck-card-widget {
    container-type: inline-size;
}

.deck-card-commanders {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin: 0 0 var(--space-1);
}

.deck-card-commander-link {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: none;
    color: var(--accent-color);
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.deck-card-commander-title,
.deck-card-commander-subtitle {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deck-card-commander-subtitle {
    color: var(--text-muted);
    font-size: 0.82em;
    font-style: italic;
    font-weight: 500;
}

.deck-card-commander-link:hover,
.deck-card-commander-link:focus-visible {
    color: color-mix(in srgb, var(--accent-color) 72%, white);
    text-decoration: underline;
}

.deck-card-commander-link:focus-visible {
    outline: 1px solid var(--accent-color);
    outline-offset: 2px;
}

.deck-card-commanders-ampersand {
    display: none;
    align-self: center;
    color: white;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

@container (min-width: 280px) {
    .deck-card-commanders-paired {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        align-items: center;
        gap: var(--space-2);
    }

    .deck-card-commanders-paired .deck-card-commanders-ampersand {
        display: block;
    }

    .deck-card-commander-partner {
        align-items: flex-end;
        text-align: right;
    }
}

.deck-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.9;
    transition: transform 0.3s ease;
}

.deck-card-image-split {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.deck-card-image-pane {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.deck-card-image-pane-primary {
    -webkit-mask-image: linear-gradient(115deg, #000 calc(50% - 0.5px), transparent calc(50% + 0.5px));
    mask-image: linear-gradient(115deg, #000 calc(50% - 0.5px), transparent calc(50% + 0.5px));
}

.deck-card-image-pane-secondary {
    -webkit-mask-image: linear-gradient(115deg, transparent calc(50% - 0.5px), #000 calc(50% + 0.5px));
    mask-image: linear-gradient(115deg, transparent calc(50% - 0.5px), #000 calc(50% + 0.5px));
}

/* Each source gets its own side-centered viewport. The extra 20% covers the
   diagonal overlap while placing the image centers at 27% and 73% of the
   overall widget instead of at the shared 50% midpoint. */
.deck-card-image-pane .deck-card-image {
    position: absolute;
    top: 0;
    width: 70%;
    height: 100%;
    object-position: center;
}

.deck-card-image-pane-primary .deck-card-image {
    right: 38%;
}

.deck-card-image-pane-secondary .deck-card-image {
    left: 38%;
}

.deck-card-image-split::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(
        115deg,
        transparent calc(50% - 0.75px),
        rgba(255, 255, 255, 0.55) calc(50% - 0.75px),
        rgba(255, 255, 255, 0.55) calc(50% + 0.75px),
        transparent calc(50% + 0.75px)
    );
}

.deck-card-widget:hover .deck-card-image {
    transform: scale(1.05);
    opacity: 1;
}

/* ── Deck plate widget ─────────────────────────────────────────────────────────
   The default deck card: a slightly tilted art plate overhanging a body plate.
   Two overlapping rounded rects rather than one die-cut outline, so borders,
   shadows, focus rings, and grid hit-boxes all stay sane. The chips on the art
   are buttons — favorite toggles, visibility opens the owner flow, format opens
   the glossary. DeckCardWidget above is the retired simple design. */
.deck-plate {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.deck-plate-clickable {
    cursor: pointer;
}

.deck-plate-clickable:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 3px;
    border-radius: var(--radius-3xl);
}

.deck-plate-art {
    position: relative;
    z-index: 1;
    margin: 10px 12px -20px;
    aspect-ratio: 620 / 453;
    border-radius: var(--radius-3xl);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--deck-header-bg);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
    /* Tilted enough to read as intentional styling, not a rendering accident. */
    transform: rotate(-2.2deg);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.deck-plate:hover .deck-plate-art {
    transform: rotate(-0.4deg) translateY(-3px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
}

@media (prefers-reduced-motion: reduce) {
    .deck-plate-art,
    .deck-plate:hover .deck-plate-art {
        transform: none;
        transition: none;
    }
}

.deck-plate-art-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
}

.deck-plate-art .deck-card-image,
.deck-plate-art .deck-card-image-split {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Commander identity lives in one scrim block anchored to the art, so long
   partner names wrap inside it rather than floating past the plate's edge. */
.deck-plate-scrim {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-px);
    padding: 30px 12px 10px;
    background: linear-gradient(180deg, transparent, rgba(2, 4, 8, 0.85));
    pointer-events: none;
}

.deck-plate-scrim .deck-card-commander-link {
    pointer-events: auto;
    font-size: 13px;
    /* Toned from the raw accent so the deck name (body plate) stays the anchor. */
    color: color-mix(in srgb, var(--accent-color) 55%, white);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.deck-plate-scrim .deck-card-commander-subtitle {
    color: rgba(255, 255, 255, 0.72);
}

.deck-plate-partner-row {
    display: flex;
    align-items: baseline;
    gap: var(--space-1-5);
    margin-left: var(--space-4);
    min-width: 0;
}

.deck-plate-ampersand {
    color: rgba(255, 255, 255, 0.85);
    font-size: 15px;
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.deck-plate-art-overlay {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
}

/* Status chips: interactive, top-right of the art. */
.deck-plate-chips {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1-5);
}

.deck-plate-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-px);
    padding: 4px 9px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(8, 10, 14, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: white;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.deck-plate-chip:hover,
.deck-plate-chip:focus-visible {
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.deck-plate-chip-main {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.deck-plate-chip-sub {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.75;
}

/* The owner's target bracket, in the estimate's place. */
.deck-plate-chip-sub.is-target {
    color: var(--accent-color);
    opacity: 1;
}

.deck-plate-chip--fav {
    flex-direction: row;
    gap: 5px;
    font-variant-numeric: tabular-nums;
}

.deck-plate-chip--fav.favorited {
    color: var(--favorite-color);
    border-color: var(--favorite-color);
}

/* Signed-out: the count still informs, but the chip stops pretending to be a
   control. */
.deck-plate-chip.chip-static {
    cursor: default;
    opacity: 0.75;
}

.deck-plate-chip.chip-static:hover {
    border-color: rgba(255, 255, 255, 0.16);
    transform: none;
}

/* Body plate: the deck's identity. Top padding clears the overhanging art. */
.deck-plate-body {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 30px 16px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-3xl);
    box-shadow: var(--popup-shadow);
}

.deck-plate-title-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.deck-plate-name {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deck-plate-affinity {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.deck-plate-companion {
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deck-plate-companion-tag {
    font-size: 10px;
    opacity: 0.7;
}

/* The deck's tags, between its name and the count/date row, so every plate
   keeps them in one place and a row of plates scans evenly. */
.deck-plate-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    margin: var(--space-1) 0 0;
}

.deck-plate-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    margin-top: auto;
    padding-top: var(--space-1-5);
    font-size: 12px;
    color: var(--text-muted);
}

/* A deck that breaks its format's rules: the count in the theme's danger
   color, the problems in its tooltip, as the Builder's rail shows them. */
.deck-plate-count.invalid {
    color: var(--danger-color);
    font-weight: 600;
    cursor: help;
}

.deck-plate-updated {
    font-size: 11px;
}

/* Card zoom control, shown beside the view-mode toggle on the views that draw card
   previews. Hidden in List view, which has no preview to resize. */
.toolbar-card-scale {
    display: inline-flex;
    align-items: center;
    gap: var(--space-0-5);
}

.toolbar-card-scale-value {
    min-width: 3.2em;
    text-align: center;
    font-size: 0.78em;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    user-select: none;
}

.toolbar-card-scale .toolbar-view-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ── Site footer (LegalFooter) ─────────────────────────────── */
/* The link columns by category, then the socials and the fine print. The
   static pages draw the same footer (public/static/footer.js, styled in
   arcane-pages.css). The grid fits the pane the footer sits in, not the
   window: it renders at the foot of every panel, the narrow side pane
   included, so a narrow pane gets two columns, or one. */
.legal-footer {
    container-type: inline-size;
    width: 100%;
    box-sizing: border-box;
    margin-top: auto;
    padding: var(--space-8) var(--space-4);
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* A card under the links and the fine print: the footer sits over the
   panel's art (and a season's fog), which made its small text hard to read,
   on phones especially. Translucent, so the art still shows around it. */
.legal-footer-inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    max-width: 880px;
    margin: 0 auto;
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-2xl);
    background: color-mix(in srgb, var(--panel-bg-opaque) 82%, transparent);
}

/* Two by two in any pane narrower than four columns need, and four across in a
   wide one: never the 3 + 1 that wrapping by a minimum width gave, and one
   column only where two cannot fit (a pane under 200px). The footer measures
   its own width (container-type above), since it sits at the foot of every
   panel, the narrow side pane and a phone included. */
.legal-footer-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6) var(--space-5);
}

@container (min-width: 600px) {
    .legal-footer-columns {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@container (max-width: 200px) {
    .legal-footer-columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 400px) {
    .legal-footer {
        padding: var(--space-6) var(--space-2);
    }

    .legal-footer-inner {
        padding: var(--space-4) var(--space-3);
    }

    .legal-footer-columns {
        column-gap: var(--space-3);
    }
}

/* On a phone the page is one scroll, so a tab with nothing in it yet (no deck
   loaded, nothing searched) would show its footer right under a lone
   placeholder. The placeholder fills the screen instead, so the footer starts
   below the fold and is only seen by scrolling to it. */
@media (max-width: 768px) {
    .empty-deck {
        box-sizing: border-box;
        min-height: calc(100vh - var(--mobile-bottom-bars, 0px));
        min-height: calc(100dvh - var(--mobile-bottom-bars, 0px));
    }

    /* Search's empty scroller: it outranks the scroller's own `min-height: 0`
       (search.css, mobile_fab.css) by specificity. */
    .search-panel.mobile-overlay .search-results-wrapper:has(.search-hint, .no-results) {
        box-sizing: border-box;
        min-height: calc(100vh - var(--mobile-bottom-bars, 0px));
        min-height: calc(100dvh - var(--mobile-bottom-bars, 0px));
    }
}

.legal-footer-heading {
    margin: 0 0 var(--space-2);
    padding-bottom: var(--space-1-5);
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.legal-footer-column ul {
    display: flex;
    flex-direction: column;
    gap: var(--space-1-5);
    margin: 0;
    padding: 0;
    list-style: none;
}

.legal-footer-column a {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
}

.legal-footer-column a:hover,
.legal-footer-column a:focus-visible {
    color: var(--accent-color);
    text-decoration: underline;
}

/* The socials and the fine print sit centred under the columns. */
.legal-footer-base {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    text-align: center;
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-primary);
    line-height: 1.45;
}

.legal-footer-base p {
    max-width: 640px;
    margin: 0;
}

.legal-footer-base p a {
    color: var(--accent-color);
    text-decoration: underline;
}

.legal-footer-socials {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2-5);
    margin-bottom: var(--space-1);
}

.legal-footer-socials a {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.legal-footer-socials a:hover,
.legal-footer-socials a:focus-visible {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* The icon itself: the shape is a mask set inline with each link's SVG. */
.legal-footer-socials span {
    width: 16px;
    height: 16px;
    background-color: currentColor;
}

.deck-plate-scrim .deck-plate-partner-row:first-child { margin-left: 0; }


/* The art edits a saved deck's cover; the explicit Load button opens the deck. */
.deck-plate-cover-edit {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: inherit;
    background: transparent;
    cursor: pointer;
}
.deck-plate-cover-edit:hover { background: rgba(var(--accent-rgb), 0.08); }
.deck-plate-cover-edit:focus-visible { outline: 2px solid var(--accent-color); outline-offset: calc(-1 * var(--space-1)); }
.deck-plate-cover-edit:disabled { cursor: default; opacity: 0.5; }

.deck-plate .deck-plate-art button.deck-plate-cover-edit:not(:disabled),
.deck-plate .deck-plate-art button.deck-plate-cover-edit:not(:disabled):hover,
.deck-plate .deck-plate-art button.deck-plate-cover-edit:not(:disabled):active { transform: none; translate: none; scale: none; }

.deck-plate-art .deck-cover-picture > img { object-fit: cover; }
.deck-plate-art .deck-cover-picture .card-image-outline { display: none; }
.deck-plate-art .deck-card-image-pane > .deck-card-image { width: 70%; }
