/* Card Popup - Revamped Layout */

/* Remove default overlay padding */
#card-popup-overlay.popup {
    padding-top: 0;
}

#card-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--colour-popup-paper);
    border: 1px solid var(--colour-secondary);
    width: calc(100vw - 160px);
    max-width: 1600px;
    /* Definite height so the popup stays the SAME size on every tab —
       a tall tab (Prices) scrolls inside .information instead of
       growing the box. Sized to the card image (--card-hight-md) plus
       padding + meta, capped at 88vh for short viewports. */
    height: min(88vh, calc(var(--card-hight-md) + 185px));
    max-height: 88vh;
    /* No right padding — the right column re-pads itself so the
       .information scrollbar can sit flush against the popup edge. */
    padding: 32px 0 32px 32px;
    border-radius: 13px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 40px;
    overflow: hidden;
}

/* ========================================
   LEFT COLUMN: Card Image + Meta
   ======================================== */

.popup-left {
    display: grid;
    grid-template-rows: auto auto;
    gap: 16px;
    min-width: var(--card-width-md);
    max-width: var(--card-width-md);
}

.card-img {
    display: grid;
    justify-items: center;
}

#popup-image {
    max-width: var(--card-width-md);
    max-height: var(--card-hight-md);
    width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Make fallback placeholder cards clearly muted without affecting real card art */
#popup-image.is-placeholder-image {
    filter: grayscale(0.72) saturate(0.72) brightness(0.84) contrast(0.95);
    opacity: 0.9;
}

/* Series and Expansion Meta */
.popup-meta {
    display: grid;
    gap: 8px;
}

.popup-series {
    display: grid;
    gap: 4px;
    padding: 8px 12px;
    background-color: var(--colour-paper);
    border-radius: var(--radius-xs);
}

.popup-series .meta-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--colour-text);
    opacity: 0.6;
}

.popup-series .meta-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--colour-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.popup-series .meta-value:hover {
    color: var(--colour-primary);
}

.popup-expansion {
    display: grid;
    justify-items: center;
    padding: 8px;
    background-color: var(--colour-paper);
    border-radius: var(--radius-xs);
}

.popup-expansion a {
    display: grid;
    place-items: center;
}

.popup-expansion-logo {
    max-height: 48px;
    max-width: 100%;
    width: auto;
    height: auto;
}

/* ========================================
   RIGHT COLUMN: Header, Tabs, Content
   ======================================== */

.popup-right {
    display: grid;
    /* minmax(0, 1fr) on the .information row lets it shrink below its
       content size so the panel scrolls instead of stretching the popup. */
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 8px;
    overflow: hidden;
    min-height: 0;
    /* Re-pad the right inset that #card-popup gave up. .information
       escapes this padding (negative margin) so its scrollbar lands
       on the popup edge; header/number/tabs stay inset. */
    padding-right: 32px;
}

/* Header Row: Name + Menu */
.popup-header {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 12px;
}

.popup-name-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.popup-prefix,
.popup-suffix {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    background: var(--colour-border);
    border-radius: 4px;
    flex-shrink: 0;
}

.popup-prefix.visible,
.popup-suffix.visible {
    display: inline-flex;
}

.popup-prefix img,
.popup-suffix img {
    height: 18px;
    width: auto;
}

.popup-name {
    display: inline-flex;
    align-items: baseline;
    gap: 0.22em;
    font-weight: 700;
    font-size: var(--text-lg);
    line-height: 1.18;
    color: var(--colour-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-bottom: 3px;
    min-width: 0;
}

.popup-name-part {
    display: inline-block;
    min-width: 0;
    line-height: inherit;
    vertical-align: baseline;
}

.popup-name-part--normal {
    flex: 0 1 auto;
    min-width: 0;
}

.popup-name-part.name-symbol--ex-era {
    color: inherit;
    font-family: Arial, Helvetica, var(--font-main, sans-serif);
    font-size: inherit;
    font-weight: 900;
    font-style: italic;
    line-height: 1;
    letter-spacing: 0;
    padding-left: 0.08em;
    transform: skewX(-7deg) scaleX(0.9);
    transform-origin: left center;
    text-shadow: 0.018em 0 currentColor;
}

.popup-name-part--small {
    font-size: 0.6em;
    font-weight: 700;
    line-height: inherit;
    align-self: baseline;
    flex: 0 0 auto;
}

.popup-name-part--small:has(+ .name-symbol--lv-x) {
    font-size: 0.48em;
}

.popup-name-part--annotation {
    font-size: 0.6em;
    font-style: italic;
    font-weight: 700;
    line-height: inherit;
    align-self: baseline;
    flex: 0 0 auto;
}

.popup-name-part--symbol {
    display: inline-flex;
    align-self: center;
    align-items: center;
    flex: 0 0 auto;
    overflow: hidden;
}

.popup-name-part--symbol img {
    display: block;
    width: auto;
    height: 1.05em;
    max-height: 28px;
    object-fit: contain;
}

.popup-name-part--symbol.name-symbol--mega img,
.popup-name-part--symbol.name-symbol--primal img {
    height: 1.14em;
}

.popup-name-part--symbol.name-symbol--lv-x {
    overflow: visible;
    color: #b88916;
    font-family: "Arial Black", Arial, var(--font-main, sans-serif);
    font-size: 1.16em;
    font-weight: 900;
    font-style: normal;
    line-height: 1;
    padding: 0 0.03em 0.05em;
    text-shadow: none;
    transform: skewX(-5deg) scaleX(1.04);
    transform-origin: center;
    -webkit-text-stroke: 0;
}

.popup-typing,
.popup-rarity {
    display: none;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    border-radius: 0;
    background: transparent;
}

.popup-typing.visible,
.popup-rarity.visible {
    display: inline-flex;
}

.popup-typing img,
.popup-rarity img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.rarity-composite {
    --rarity-icon-size: 34px;
    --rarity-suffix-size: calc(var(--rarity-icon-size) * 0.88);
    --rarity-suffix-offset: -2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-width: var(--rarity-icon-size);
    height: var(--rarity-icon-size);
    line-height: 1;
    white-space: nowrap;
}

.rarity-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: var(--rarity-icon-size);
    color: #111;
    flex: 0 0 auto;
}

.rarity-symbol-image {
    display: block;
    width: var(--rarity-icon-size);
    height: var(--rarity-icon-size);
    object-fit: contain;
}

.rarity-symbol--silver {
    color: #8f969d;
}

.rarity-symbol--silver .rarity-symbol-image {
    filter: invert(62%) sepia(7%) saturate(215%) hue-rotate(169deg) brightness(92%) contrast(88%);
}

.rarity-symbol-text,
.rarity-symbol-suffix {
    display: inline-block;
    color: currentColor;
    font-family: "Roboto Condensed", "Arial Narrow", "Helvetica Neue Condensed", Impact, sans-serif;
    font-size: var(--rarity-suffix-size);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    transform: scaleX(0.78);
    transform-origin: left center;
    text-shadow: 0.02em 0 currentColor;
}

.rarity-symbol-text {
    margin-right: -2px;
}

.rarity-symbol-suffix {
    margin-left: var(--rarity-suffix-offset);
}

.rarity-composite--long {
    --rarity-suffix-size: calc(var(--rarity-icon-size) * 0.62);
    --rarity-suffix-offset: -2px;
}

.rarity-composite--multi {
    gap: 0;
}

[data-theme="dark"] .rarity-composite:has(.rarity-symbol--black) {
    filter:
        drop-shadow(0 0 1px rgba(255, 255, 255, 0.55))
        drop-shadow(0 0 2px rgba(255, 255, 255, 0.28))
        drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}

[data-theme="dark"] .popup-rarity img:not(.rarity-symbol-image) {
    filter:
        drop-shadow(0 0 1px rgba(255, 255, 255, 0.55))
        drop-shadow(0 0 2px rgba(255, 255, 255, 0.28))
        drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
}

/* Hamburger Menu Button */
.popup-menu-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--colour-accent);
    border-radius: var(--radius-xs);
    color: var(--colour-text);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.popup-menu-btn:hover {
    background-color: var(--colour-text-muted);
    color: var(--colour-primary);
}

.popup-menu-btn:focus-visible {
    outline: 2px solid var(--colour-primary);
    outline-offset: 2px;
}

/* Dropdown Menu */
.popup-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--colour-popup-paper);
    border: 1px solid var(--colour-accent);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    min-width: 240px;
    padding: 8px 0;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.popup-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.popup-dropdown-item {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-auto-flow: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--colour-text);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.popup-dropdown-item:hover {
    background-color: var(--colour-text-muted);
}

.popup-dropdown-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.popup-dropdown-item-secondary {
    opacity: 0.7;
}

.popup-dropdown-item-secondary:hover {
    opacity: 1;
}

.popup-dropdown-divider {
    margin: 8px 0;
    border: none;
    border-top: 1px solid var(--colour-accent);
}

/* Dropdown Submenu */
.popup-dropdown-submenu {
    position: relative;
}

.popup-dropdown-submenu-trigger {
    justify-content: flex-start;
}

.popup-dropdown-submenu-trigger .submenu-chevron {
    margin-left: auto;
    opacity: 0.5;
}

.popup-submenu-content {
    position: absolute;
    left: 100%;
    top: 0;
    background: var(--colour-popup-paper);
    border: 1px solid var(--colour-accent);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.popup-dropdown-submenu:hover .popup-submenu-content {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Number Row */
.popup-number {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--colour-text);
    opacity: 0.7;
    padding-bottom: 12px;
}

/* ========================================
   TAB BAR
   ======================================== */

.card-info-selector {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 24px;
    cursor: pointer;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    margin-top: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.card-info-selector::-webkit-scrollbar {
    display: none;
}

/* Sliding underline indicator */
.card-info-selector::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: var(--indicator-left, 0);
    width: var(--indicator-width, 0);
    height: 3px;
    background-color: var(--colour-primary);
    border-radius: 2px;
    transition: left 0.3s ease, width 0.3s ease;
}

.card-info-selector .card-tab {
    padding: 8px 0;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-md);
    color: var(--colour-text);
    opacity: 0.6;
    white-space: nowrap;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.card-info-selector .card-tab:hover {
    opacity: 1;
    color: var(--colour-primary);
}

.card-info-selector .card-tab.active {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .card-info-selector::after {
        transition: none;
    }
}

/* ========================================
   TAB PANELS / INFORMATION AREA
   ======================================== */

.information {
    display: grid;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    /* Escape .popup-right's right padding so the scrollbar sits flush
       against the popup edge; padding-right keeps content inset. */
    margin-right: -32px;
    padding-right: 32px;
    /* Subtle scrollbar — transparent until the user scrolls (JS adds
       .is-scrolling) or hovers the panel. */
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color 0.3s ease;
}

.information:hover,
.information.is-scrolling {
    scrollbar-color: var(--colour-text-muted) transparent;
}

.information::-webkit-scrollbar {
    width: 6px;
}

.information::-webkit-scrollbar-track {
    background: transparent;
}

.information::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.information:hover::-webkit-scrollbar-thumb,
.information.is-scrolling::-webkit-scrollbar-thumb {
    background: var(--colour-text-muted);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ========================================
   PRICES TAB
   ======================================== */

/* #popup-prices-body toggles class by state: .prices-loading
   (skeleton), .prices-tab (full layout), .prices-empty (no data /
   pricing-off / error). */

.prices-loading,
.prices-empty {
    padding: var(--space-8) var(--space-4);
}

/* — Skeleton — */
.prices-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

.prices-skeleton-row {
    height: 56px;
    border-radius: var(--radius-sm);
    background: linear-gradient(
        90deg,
        var(--bar-track) 0%,
        var(--tile-tint-blue) 50%,
        var(--bar-track) 100%
    );
    background-size: 200% 100%;
    animation: prices-shimmer 1.4s linear infinite;
}

@keyframes prices-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .prices-skeleton-row { animation: none; background: var(--bar-track); }
}

/* — Empty / error state — */
.prices-empty {
    text-align: center;
    padding: var(--space-32) var(--space-16);
    color: var(--colour-text-muted);
}

.prices-empty-title {
    font-family: var(--font-header);
    font-size: var(--text-sm);
    font-weight: var(--font-weight-md);
    color: var(--colour-text);
    margin: 0 0 var(--space-4);
}

.prices-empty-sub {
    font-family: var(--font-paragraph);
    font-size: var(--text-xs);
    margin: 0;
    line-height: 1.5;
}

.prices-empty-sub a {
    color: var(--colour-secondary);
    text-decoration: underline;
}

/* — Full tab layout — */
.prices-tab {
    display: flex;
    flex-direction: column;
    gap: var(--space-16);
    padding: var(--space-8) var(--space-4) var(--space-16);
    font-variant-numeric: tabular-nums;
}

/* Shared trend colours — paired with ▲ / ▼ glyphs in markup (WCAG 1.4.1). */
.prices-trend--up   { color: var(--colour-trend-positive); }
.prices-trend--down { color: var(--colour-trend-negative); }
.prices-trend--flat { color: var(--colour-trend-neutral); }

.prices-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
}

.prices-section-title {
    font-family: var(--font-header);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-md);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--colour-text-muted);
}

/* Panel 1 — variant pills */
.prices-pills {
    display: flex;
    gap: var(--space-8);
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.prices-pills::-webkit-scrollbar { display: none; }

.prices-pill {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: var(--space-8) var(--space-12);
    border: 1px solid var(--bar-track);
    border-radius: var(--radius-sm);
    background: var(--colour-paper);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.prices-pill:hover { border-color: var(--colour-trend-positive); }

.prices-pill.active {
    background: var(--colour-trend-positive-bg);
    border-color: var(--colour-trend-positive);
}

.prices-pill-name {
    font-size: var(--text-xs);
    color: var(--colour-text-muted);
    font-weight: var(--font-weight-md);
}

.prices-pill-price {
    font-family: var(--font-header);
    font-size: var(--text-sm);
    font-weight: var(--font-weight-lg);
    color: var(--colour-text);
}

.prices-pill-delta {
    font-size: 10px;
    font-weight: var(--font-weight-md);
    white-space: nowrap;
}

/* Panel 2 — hero price */
.prices-hero {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-12) 0;
    border-bottom: 1px solid var(--bar-track);
}

.prices-hero-price {
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 32px;
    line-height: 1.05;
    color: var(--colour-text);
    letter-spacing: -0.5px;
}

.prices-hero-secondary {
    font-size: var(--text-xs);
    color: var(--colour-text-muted);
}

.prices-hero-delta {
    margin-top: var(--space-4);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-md);
}

/* Panel 3 — time-range selector */
.prices-range-tabs {
    display: flex;
    gap: 2px;
    background: var(--bar-track);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.prices-range-tab {
    flex: 1;
    padding: var(--space-4) var(--space-8);
    font-family: var(--font-header);
    font-size: 11px;
    font-weight: var(--font-weight-md);
    color: var(--colour-text-muted);
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.prices-range-tab:hover { color: var(--colour-text); }

.prices-range-tab.active {
    background: var(--colour-trend-positive-bg);
    color: var(--colour-trend-positive);
}

/* Panel 4 — chart */
.prices-chart {
    height: 120px;
}

.prices-chart-svg {
    display: block;
    width: 100%;
    height: 120px;
}

.prices-chart-grid {
    stroke: var(--colour-text);
    stroke-width: 1;
    opacity: 0.06;
    vector-effect: non-scaling-stroke;
}

/* Chart line + gradient — styled here, not via SVG attributes, so the
   theme-aware var() tokens resolve (var() only works in CSS props). */
.prices-chart-line {
    fill: none;
    stroke: var(--colour-trend-positive);
    stroke-width: 2;
}

.prices-grad-top {
    stop-color: var(--colour-trend-positive);
    stop-opacity: 0.20;
}

.prices-grad-bottom {
    stop-color: var(--colour-trend-positive);
    stop-opacity: 0;
}

.prices-chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    padding: 0 var(--space-16);
    text-align: center;
    font-size: var(--text-xs);
    color: var(--colour-text-muted);
    background: var(--bar-track);
    border-radius: var(--radius-sm);
}

/* Panel 5 — range bars */
.prices-bars {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

.prices-bar {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.prices-bar-label {
    font-size: var(--text-xs);
    color: var(--colour-text-muted);
    font-weight: var(--font-weight-md);
}

.prices-bar-track {
    position: relative;
    height: 6px;
    border-radius: 3px;
    background: var(--bar-track);
}

.prices-bar-marker {
    position: absolute;
    top: 50%;
    width: 10px;
    height: 10px;
    background: var(--colour-pricing-gold);
    border-radius: 2px;
    transform: translate(-50%, -50%) rotate(45deg);
}

.prices-bar-ends {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--colour-text);
}

/* Panel 6 — key stats grid (3×2) */
.prices-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--bar-track);
    border: 1px solid var(--bar-track);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.prices-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-8);
    background: var(--colour-paper);
}

.prices-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--colour-text-muted);
}

.prices-stat-value {
    font-family: var(--font-header);
    font-size: var(--text-sm);
    font-weight: var(--font-weight-lg);
    color: var(--colour-text);
}

.prices-stat-value--empty {
    color: var(--colour-text-muted);
    font-weight: var(--font-weight-md);
}

/* Panel 7 — marketplace comparison */
.prices-markets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);
}

.prices-market {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-12);
    border: 1px solid var(--bar-track);
    border-radius: var(--radius-sm);
    background: var(--colour-paper);
}

.prices-market-head {
    display: flex;
    align-items: center;
    gap: var(--space-8);
}

.prices-market-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.prices-market-dot--cardmarket { background: var(--colour-trend-positive); }
.prices-market-dot--tcgplayer  { background: var(--colour-pricing-gold); }

.prices-market-name {
    font-size: var(--text-xs);
    font-weight: var(--font-weight-md);
    color: var(--colour-text);
}

.prices-market-price {
    font-family: var(--font-header);
    font-size: var(--text-md);
    font-weight: var(--font-weight-lg);
    color: var(--colour-text);
}

.prices-market-row {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
}

.prices-market-k { color: var(--colour-text-muted); }
.prices-market-v { color: var(--colour-text); }

.prices-market-nodata {
    font-size: var(--text-xs);
    color: var(--colour-text-muted);
    padding: var(--space-8) 0;
}

/* Panel 8 — price alerts */
.prices-alerts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-8);
}

.prices-alert-chip {
    padding: var(--space-4) var(--space-12);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-md);
    color: var(--colour-text-muted);
    background: var(--colour-paper);
    border: 1px solid var(--bar-track);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.prices-alert-chip:hover {
    border-color: var(--colour-pricing-gold);
    color: var(--colour-pricing-gold);
}

/* Panel 9 — buy links */
.prices-buy {
    display: flex;
    gap: var(--space-8);
}

.prices-buy-btn {
    flex: 1;
    padding: var(--space-8) var(--space-12);
    text-align: center;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-md);
    color: var(--colour-text);
    background: transparent;
    border: 1px solid var(--bar-track);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.prices-buy-btn:hover {
    border-color: var(--colour-pricing-gold);
    background: var(--colour-pricing-gold-bg);
}

.prices-disclosure {
    margin: var(--space-8) 0 0;
    text-align: center;
    font-size: 9px;
    line-height: 1.4;
    color: var(--colour-text-muted);
}

.line {
    height: 2px;
    background-color: var(--colour-accent);
    margin: 12px 0;
    border-radius: 1px;
}

.card-variant-header {
    display: grid;
    grid-template-columns: 3fr 1fr;
    align-items: center;
    padding: var(--space-8) var(--space-16);
    font-weight: 700;
    font-size: var(--text-md);
}

#popup-total-quantity {
    display: grid;
    justify-items: center;
    font-size: var(--text-md);
}

/* Variant Items */
.variants-container {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    justify-items: stretch;
    row-gap: var(--space-8);
}

.variant-item {
    display: grid;
    grid-template-columns: 3fr 1fr;
    align-items: center;
    padding: var(--space-12) var(--space-16);
    border-radius: var(--radius-xs);
    min-height: 48px;
}

.variant-item strong {
    font-size: var(--text-md);
    font-weight: var(--font-weight-md);
    line-height: 1;
}

.variant-details {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.variant-source {
    color: var(--colour-text-muted);
    font-size: var(--text-xs);
    line-height: 1.2;
}

.variants-container .card-counter {
    align-items: center;
    justify-items: center;
}

.variants-container .card-count {
    font-size: var(--text-md);
    line-height: 1;
    background: transparent;
    border: none;
    outline: none;
    color: inherit;
    font-family: inherit;
    font-weight: inherit;
    text-align: center;
    width: 100%;
    max-width: 4ch;
    padding: 0;
    cursor: pointer;
    -moz-appearance: textfield;
}
.variants-container .card-count::-webkit-outer-spin-button,
.variants-container .card-count::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.variants-container .card-count:focus {
    cursor: text;
    background: var(--colour-border);
    border-radius: 4px;
}

.variants-container .card-counter button {
    line-height: 1;
    border: none;
    background: none;
    color: var(--colour-secondary);
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.variants-container .card-counter button:hover {
    color: var(--colour-primary);
}

.variants-container .card-counter button:disabled,
.variants-container .card-counter button.disabled {
    color: var(--colour-text-muted);
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

/* Coming Soon Message */
.coming-soon-message {
    display: grid;
    place-items: center;
    padding: 48px 16px;
    font-size: 16px;
    font-weight: 500;
    color: var(--colour-text);
    opacity: 0.5;
}

.coming-soon-message .coming-soon-badge {
    font-size: 13px;
    padding: 5px 12px;
    margin-top: 8px;
}

/* ========================================
   NAVIGATION ARROWS
   ======================================== */

.popup-nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1001;
    width: 52px;
    height: 72px;
    aspect-ratio: 286 / 400;
    border: 1px solid var(--colour-accent);
    border-radius: var(--radius-sm, 8px);
    background: var(--colour-popup-paper);
    color: var(--colour-text);
    cursor: pointer;
    display: grid;
    place-items: center;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.popup-nav-arrow:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.05);
    color: var(--colour-primary);
}

.popup-nav-arrow:focus-visible {
    outline: 2px solid var(--colour-primary);
    outline-offset: 2px;
}

.popup-nav-prev {
    left: 2%;
}

.popup-nav-next {
    right: 2%;
}

.popup-nav-arrow.hidden {
    visibility: hidden;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .popup-nav-arrow {
        transition: none;
    }
    .popup-nav-arrow:hover {
        transform: translateY(-50%);
    }
}

/* ========================================
   TOAST NOTIFICATION
   ======================================== */

.popup-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--colour-text);
    color: var(--colour-bg);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

.popup-toast.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ========================================
   POPUP ICON (on card grid)
   ======================================== */

.popup-icon {
    cursor: pointer;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    #card-popup {
        grid-template-columns: 1fr;
        width: 95vw;
        /* Mobile stacks to one column — drop the desktop fixed height
           and let the whole popup scroll as a unit instead. */
        height: auto;
        max-height: 90vh;
        overflow-y: auto;
        padding: 16px;
        gap: 16px;
    }

    .popup-left {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto;
        gap: 12px;
    }

    /* Mobile keeps 16px padding all round and scrolls as one unit —
       drop the desktop flush-scrollbar negative-margin trick. */
    .popup-right { padding-right: 0; }
    .information { margin-right: 0; padding-right: 0; }

    .card-img {
        /* No changes needed */
    }

    #popup-image {
        max-width: 120px;
        max-height: 168px;
    }

    .popup-meta {
        flex: 1;
    }

    .popup-name {
        font-size: var(--text-md);
    }

    .popup-typing img,
    .popup-rarity img {
        width: 32px;
        height: 32px;
    }

    .popup-nav-arrow {
        width: 40px;
        height: 56px;
    }

    .popup-nav-prev {
        left: 4px;
    }

    .popup-nav-next {
        right: 4px;
    }

    .card-info-selector {
        gap: 16px;
    }

    .variant-item strong {
        font-size: var(--text-sm);
    }
}

@media (max-width: 480px) {
    .popup-left {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    #popup-image {
        max-width: 160px;
        max-height: 224px;
    }

    .popup-meta {
        width: 100%;
    }

    .popup-dropdown {
        right: -16px;
        min-width: 180px;
    }
}

/* ========================================
   QUANTITY STEPPER FEEDBACK
   ======================================== */

/* Kill mobile 300ms tap delay */
.card-button,
.card-counter button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Minimum touch target (WCAG 2.5.5) */
.card-button {
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
}

/* Press feedback */
.card-button:active {
  transform: scale(0.88);
  transition: transform 0.08s ease;
}

.card-button:not(:active) {
  transition: transform 0.15s ease;
}

/* Quantity change pulse animation */
@keyframes qty-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); color: var(--colour-primary); }
  100% { transform: scale(1); }
}

.card-count.qty-changed {
  animation: qty-pulse 0.25s ease-out;
}

/* Subtle "saving" indicator — count goes slightly transparent while persisting */
.card-count.syncing {
  opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
  .card-button:active {
    transform: none;
  }
  .card-count.qty-changed {
    animation: none;
  }
}
